eftcmdr 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +25 -4
- data/bin/eftcmdr-ssh-setup +7 -1
- data/bin/eftcmdr-ssh-wrapper +2 -0
- data/bin/eftcmdr-ssh-wrapper.sh +3 -0
- data/eftcmdr.gemspec +3 -3
- data/examples/bar.yml +5 -5
- data/examples/baz.yml +70 -0
- data/examples/foo.yml +5 -5
- data/examples/qux.yml +18 -3
- data/lib/eftcmdr.rb +15 -8
- data/lib/eftcmdr/version.rb +2 -2
- metadata +7 -4
- data/examples/bar.apps +0 -1
- data/examples/foo.apps +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9a6c7ff546d6168863233defa60377bcc43ec2d
|
4
|
+
data.tar.gz: 5bc174030b292200451da7b62842d4b9bd6e59ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8245e24565df7b0ed6c5e17853dc3ffaaef4c9521f8b1421d8a4a777312321b4dc991e8bcf117de011f824a4b28201e8238676b1cf73a8ee1d84b8fab92d6b27
|
7
|
+
data.tar.gz: f202123fc99b2e209087839352152ac1695526ca8b77384a6c53579fe251c3b8429968fb69a6bf545bab5cdae2744de1c6b422a23564a79001c7ca7a7c68b7a7
|
data/README.md
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
File : README.md
|
4
4
|
Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
Date : 2014-
|
5
|
+
Date : 2014-03-03
|
6
6
|
|
7
7
|
Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
-
Version : v0.4.
|
8
|
+
Version : v0.4.1
|
9
9
|
|
10
10
|
[]: }}}1
|
11
11
|
|
@@ -35,14 +35,35 @@ $ eftcmdr examples/hello.yml
|
|
35
35
|
|
36
36
|
### SSH
|
37
37
|
|
38
|
+
[]: {{{2
|
39
|
+
|
38
40
|
You can use `eftcmdr-ssh-setup` to generate a
|
39
41
|
`~/.ssh/authorized_keys` from `~/.eftcmdr.d/*.{pub,yml}` (see
|
40
42
|
`examples/`). This allows you to use `eftcmdr` to provide a menu
|
41
43
|
over `ssh -t` that allows selected users to perform selected
|
42
44
|
actions.
|
43
45
|
|
44
|
-
**NB**: be careful what you allow -- access to e.g.
|
45
|
-
makes it trivial to get complete shell access.
|
46
|
+
**NB**: be careful what you allow -- access to e.g. `rails console`
|
47
|
+
or `less` makes it trivial to get complete shell access.
|
48
|
+
|
49
|
+
You may need to load e.g. `~/.profile` (e.g. when `eftcmdr` is not
|
50
|
+
in the default `$PATH`). To make this easier, you can pass a third
|
51
|
+
argument to `eftcmdr-ssh-setup` (or set `$EFTCMDR_SSH_COMMAND`) to
|
52
|
+
choose the command to be put in the `authorized_keys` file. You can
|
53
|
+
use e.g. `$( which eftcmdr-ssh-wrapper )` to wrap `eftcmdr` in a
|
54
|
+
shell script that sources `~/.eftcmdr_env` (which can e.g. be a
|
55
|
+
symlink to `~/.profile`).
|
56
|
+
|
57
|
+
[]: }}}2
|
58
|
+
|
59
|
+
### Links
|
60
|
+
|
61
|
+
→ [blog
|
62
|
+
post](http://obfusk.github.io/_/dev/2014-02-24/eft___eftcmdr__dialog_boxes_w__ruby__yaml_and_whiptail.html)
|
63
|
+
(with pictures!)
|
64
|
+
|
65
|
+
→ [more complicated example yml
|
66
|
+
file](https://gist.github.com/obfusk/9188866)
|
46
67
|
|
47
68
|
[]: }}}1
|
48
69
|
|
data/bin/eftcmdr-ssh-setup
CHANGED
@@ -2,7 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'eftcmdr'
|
4
4
|
|
5
|
+
if (%w{ --help -h } & ARGV).any?
|
6
|
+
puts 'Usage: eftcmdr-ssh-setup [<authorized_keys_file> [<dir> [<cmd>]]]'
|
7
|
+
exit 0
|
8
|
+
end
|
9
|
+
|
5
10
|
file = ARGV[0] || "#{Dir.home}/.ssh/authorized_keys"
|
6
11
|
dir = ARGV[1] || "#{Dir.home}/.eftcmdr.d"
|
12
|
+
cmd = ARGV[2] || ENV['EFTCMDR_SSH_COMMAND'] || 'eftcmdr'
|
7
13
|
|
8
|
-
EftCmdr.build_authorized_keys file, dir
|
14
|
+
EftCmdr.build_authorized_keys file, dir, cmd
|
data/eftcmdr.gemspec
CHANGED
@@ -18,10 +18,10 @@ Gem::Specification.new do |s|
|
|
18
18
|
|
19
19
|
s.licenses = %w{ LGPLv3+ }
|
20
20
|
|
21
|
-
s.executables = %w{ eftcmdr eftcmdr-ssh-setup
|
21
|
+
s.executables = %w{ eftcmdr eftcmdr-ssh-setup eftcmdr-ssh-wrapper
|
22
|
+
eftcmdr-ssh-wrapper.sh }
|
22
23
|
s.files = %w{ .yardopts README.md Rakefile eftcmdr.gemspec } \
|
23
|
-
+ Dir['examples/**/*.
|
24
|
-
+ Dir['lib/**/*.rb']
|
24
|
+
+ Dir['examples/**/*.yml'] + Dir['lib/**/*.rb']
|
25
25
|
|
26
26
|
s.add_runtime_dependency 'eft'
|
27
27
|
s.add_runtime_dependency 'obfusk-util', '>= 0.5.0'
|
data/examples/bar.yml
CHANGED
@@ -23,21 +23,21 @@ _menu_commands: &_menu_commands
|
|
23
23
|
then:
|
24
24
|
eval: eval_view_log
|
25
25
|
code: |
|
26
|
-
|
26
|
+
osh! 'echo cd "$1" && echo tail -n "$2" logfile', app, ctx[:ask_lines]
|
27
27
|
|
28
28
|
- tag: console
|
29
29
|
text: rails console
|
30
30
|
then:
|
31
31
|
eval: eval_rails_console
|
32
32
|
code: |
|
33
|
-
|
33
|
+
osh! 'echo cd "$1" && echo rails console', app
|
34
34
|
|
35
35
|
- tag: psql
|
36
36
|
text: postgresql console
|
37
37
|
then:
|
38
38
|
eval: eval_psql
|
39
39
|
code: |
|
40
|
-
|
40
|
+
osh! 'echo psql "$1"', app
|
41
41
|
|
42
42
|
- tag: reset
|
43
43
|
text: git reset
|
@@ -52,11 +52,11 @@ _menu_commands: &_menu_commands
|
|
52
52
|
then:
|
53
53
|
eval: eval_git_reset
|
54
54
|
code: |
|
55
|
-
|
55
|
+
osh! 'echo cd "$1" && echo git reset --hard', app
|
56
56
|
else:
|
57
57
|
eval: eval_git_reset_cancelled
|
58
58
|
code: |
|
59
|
-
|
59
|
+
ohai 'git reset cancelled'
|
60
60
|
|
61
61
|
menu: menu_apps
|
62
62
|
title: apps
|
data/examples/baz.yml
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
_apps: &_apps
|
2
|
+
<% apps = file.sub(/\.yml\z/, '.apps') %>
|
3
|
+
<% if File.exists? apps %>
|
4
|
+
<% File.read(apps).split.each do |x| %>
|
5
|
+
- tag: <%= x %>
|
6
|
+
text: The <%= x %> app
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
_menu_commands: &_menu_commands
|
11
|
+
menu: menu_commands
|
12
|
+
title: commands
|
13
|
+
text: Choose a command to run
|
14
|
+
choices:
|
15
|
+
|
16
|
+
- tag: log
|
17
|
+
text: view log
|
18
|
+
then:
|
19
|
+
ask: ask_lines
|
20
|
+
text: How many lines?
|
21
|
+
default: 100
|
22
|
+
validate: \A\d+\z
|
23
|
+
then:
|
24
|
+
eval: eval_view_log
|
25
|
+
code: |
|
26
|
+
osh! 'echo cd "$1" && echo tail -n "$2" logfile', app, ctx[:ask_lines]
|
27
|
+
|
28
|
+
- tag: console
|
29
|
+
text: rails console
|
30
|
+
then:
|
31
|
+
eval: eval_rails_console
|
32
|
+
code: |
|
33
|
+
osh! 'echo cd "$1" && echo rails console', app
|
34
|
+
|
35
|
+
- tag: psql
|
36
|
+
text: postgresql console
|
37
|
+
then:
|
38
|
+
eval: eval_psql
|
39
|
+
code: |
|
40
|
+
osh! 'echo psql "$1"', app
|
41
|
+
|
42
|
+
- tag: reset
|
43
|
+
text: git reset
|
44
|
+
then:
|
45
|
+
show_text: show_text_git_status
|
46
|
+
code: |
|
47
|
+
shc!('echo cd "$1" && echo git fetch --all && echo git status',
|
48
|
+
app, merge: true).stdout
|
49
|
+
then:
|
50
|
+
ask_yesno: ask_yesno_git_reset
|
51
|
+
text: Are you sure?
|
52
|
+
then:
|
53
|
+
eval: eval_git_reset
|
54
|
+
code: |
|
55
|
+
osh! 'echo cd "$1" && echo git reset --hard', app
|
56
|
+
else:
|
57
|
+
eval: eval_git_reset_cancelled
|
58
|
+
code: |
|
59
|
+
ohai 'git reset cancelled'
|
60
|
+
|
61
|
+
menu: menu_apps
|
62
|
+
title: apps
|
63
|
+
text: Choose an app
|
64
|
+
choices: *_apps
|
65
|
+
then:
|
66
|
+
eval: eval_menu_apps
|
67
|
+
code: |
|
68
|
+
app = ctx[:menu_apps][:tag]
|
69
|
+
then: *_menu_commands
|
70
|
+
|
data/examples/foo.yml
CHANGED
@@ -23,21 +23,21 @@ _menu_commands: &_menu_commands
|
|
23
23
|
then:
|
24
24
|
eval: eval_view_log
|
25
25
|
code: |
|
26
|
-
|
26
|
+
osh! 'echo cd "$1" && echo tail -n "$2" logfile', app, ctx[:ask_lines]
|
27
27
|
|
28
28
|
- tag: console
|
29
29
|
text: rails console
|
30
30
|
then:
|
31
31
|
eval: eval_rails_console
|
32
32
|
code: |
|
33
|
-
|
33
|
+
osh! 'echo cd "$1" && echo rails console', app
|
34
34
|
|
35
35
|
- tag: psql
|
36
36
|
text: postgresql console
|
37
37
|
then:
|
38
38
|
eval: eval_psql
|
39
39
|
code: |
|
40
|
-
|
40
|
+
osh! 'echo psql "$1"', app
|
41
41
|
|
42
42
|
- tag: reset
|
43
43
|
text: git reset
|
@@ -52,11 +52,11 @@ _menu_commands: &_menu_commands
|
|
52
52
|
then:
|
53
53
|
eval: eval_git_reset
|
54
54
|
code: |
|
55
|
-
|
55
|
+
osh! 'echo cd "$1" && echo git reset --hard', app
|
56
56
|
else:
|
57
57
|
eval: eval_git_reset_cancelled
|
58
58
|
code: |
|
59
|
-
|
59
|
+
ohai 'git reset cancelled'
|
60
60
|
|
61
61
|
menu: menu_apps
|
62
62
|
title: apps
|
data/examples/qux.yml
CHANGED
@@ -14,7 +14,7 @@ _menu_stuff: &_menu_stuff
|
|
14
14
|
then:
|
15
15
|
eval: eval_secret
|
16
16
|
code: |
|
17
|
-
|
17
|
+
osh! 'echo the secret is "$1!"', ctx[:ask_pass_secret].to_s
|
18
18
|
|
19
19
|
- tag: special
|
20
20
|
text: special stuff
|
@@ -48,7 +48,22 @@ _menu_stuff: &_menu_stuff
|
|
48
48
|
esc:
|
49
49
|
eval: eval_esc
|
50
50
|
code: |
|
51
|
-
|
51
|
+
ohai 'ESCAPED!'
|
52
|
+
|
53
|
+
- tag: radio
|
54
|
+
text: Radiolist
|
55
|
+
then:
|
56
|
+
radio: radio_bar
|
57
|
+
text: Choose!
|
58
|
+
choices:
|
59
|
+
- tag: first
|
60
|
+
text: '#1'
|
61
|
+
- tag: second
|
62
|
+
text: '#2'
|
63
|
+
then:
|
64
|
+
show_msg: show_msg_radio_bar
|
65
|
+
code: |
|
66
|
+
ctx[:radio_bar]
|
52
67
|
|
53
68
|
menu: menu_choose
|
54
69
|
title: choose
|
@@ -63,4 +78,4 @@ then: *_menu_stuff
|
|
63
78
|
cancel:
|
64
79
|
eval: eval_cancelled
|
65
80
|
code: |
|
66
|
-
|
81
|
+
ohai 'CANCELLED!'
|
data/lib/eftcmdr.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# File : eftcmdr.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date : 2014-02-
|
5
|
+
# Date : 2014-02-25
|
6
6
|
#
|
7
7
|
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
8
|
# Licence : LGPLv3+
|
@@ -13,6 +13,7 @@ require 'erb'
|
|
13
13
|
require 'yaml'
|
14
14
|
|
15
15
|
require 'eft'
|
16
|
+
require 'obfusk/util/message'
|
16
17
|
require 'obfusk/util/sh'
|
17
18
|
|
18
19
|
module EftCmdr
|
@@ -38,7 +39,8 @@ module EftCmdr
|
|
38
39
|
|
39
40
|
# data: file, args, context
|
40
41
|
class Data < Struct.new(:file, :args, :ctx)
|
41
|
-
%w{ sh sh? sh! shc shc? shc!
|
42
|
+
%w{ ohai onow onoe opoo sh sh? sh! shc shc? shc! osh osh? osh!
|
43
|
+
oshc osch? oshc! }.each do |m|
|
42
44
|
define_method(m) { |*a,&b| Obfusk::Util.send(m, *a, &b) }
|
43
45
|
end
|
44
46
|
def _binding; binding; end
|
@@ -138,7 +140,7 @@ module EftCmdr
|
|
138
140
|
Eft.radio spec['text'],
|
139
141
|
_opts(spec, selected: spec['selected']) do |r|
|
140
142
|
spec['choices'].each do |c|
|
141
|
-
|
143
|
+
r.choice c['tag'], c['text']
|
142
144
|
end
|
143
145
|
r.on_ok do |choice|
|
144
146
|
then_run spec['then'], state, spec['radio'].to_sym => choice
|
@@ -234,19 +236,24 @@ module EftCmdr
|
|
234
236
|
|
235
237
|
# --
|
236
238
|
|
237
|
-
# turn
|
238
|
-
|
239
|
+
# turn dir (e.g. `~/.eftcmdr.d`) into file (e.g.
|
240
|
+
# `~/.ssh/authorized_keys`): each `dir/$USER.pub` is added to `file`
|
241
|
+
# w/ forced command `cmd dir/$USER.yml $USER`; added entries are
|
242
|
+
# marked w/ a comment that includes the text `EFTCMDR` so that they
|
243
|
+
# can be ignored on subsequent runs.
|
244
|
+
def self.build_authorized_keys(file, dir, cmd) # {{{1
|
239
245
|
dir =~ %r{\A[A-Za-z0-9_./-]+\z} \
|
240
246
|
or raise InvalidFileNameError, "invalid dir name: #{dir}"
|
247
|
+
cmd =~ %r{\A[A-Za-z0-9_./-]+\z} \
|
248
|
+
or raise InvalidFileNameError, "invalid command name: #{cmd}"
|
241
249
|
original = (File.exists?(file) ? File.read(file) : '') \
|
242
250
|
.lines.reject { |l| l =~ /EFTCMDR/ }
|
243
251
|
lines = Dir["#{dir}/*.pub"].sort.map do |x|
|
244
252
|
b = File.basename x, '.pub'
|
245
253
|
b =~ %r{\A[A-Za-z0-9_.-]+\z} \
|
246
254
|
or raise InvalidFileNameError, "invalid file name: #{x}"
|
247
|
-
k = File.read(x).chomp
|
248
|
-
|
249
|
-
SSH_LINE["eftcmdr #{dir}/#{f} #{b}", k, "(EFTCMDR #{x})"]
|
255
|
+
k = File.read(x).chomp; f = x.sub /\.pub\z/, '.yml'
|
256
|
+
SSH_LINE["#{cmd} #{f} #{b}", k, "(EFTCMDR #{x})"]
|
250
257
|
end
|
251
258
|
File.open(file, 'w') do |f|
|
252
259
|
(original + lines).each { |l| f.puts l }
|
data/lib/eftcmdr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eftcmdr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix C. Stegerman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eft
|
@@ -60,6 +60,8 @@ email:
|
|
60
60
|
executables:
|
61
61
|
- eftcmdr
|
62
62
|
- eftcmdr-ssh-setup
|
63
|
+
- eftcmdr-ssh-wrapper
|
64
|
+
- eftcmdr-ssh-wrapper.sh
|
63
65
|
extensions: []
|
64
66
|
extra_rdoc_files: []
|
65
67
|
files:
|
@@ -70,13 +72,14 @@ files:
|
|
70
72
|
- examples/hello.yml
|
71
73
|
- examples/qux.yml
|
72
74
|
- examples/bar.yml
|
75
|
+
- examples/baz.yml
|
73
76
|
- examples/foo.yml
|
74
|
-
- examples/foo.apps
|
75
|
-
- examples/bar.apps
|
76
77
|
- lib/eftcmdr.rb
|
77
78
|
- lib/eftcmdr/version.rb
|
78
79
|
- bin/eftcmdr
|
79
80
|
- bin/eftcmdr-ssh-setup
|
81
|
+
- bin/eftcmdr-ssh-wrapper
|
82
|
+
- bin/eftcmdr-ssh-wrapper.sh
|
80
83
|
homepage: https://github.com/obfusk/eftcmdr
|
81
84
|
licenses:
|
82
85
|
- LGPLv3+
|
data/examples/bar.apps
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
qux quux
|
data/examples/foo.apps
DELETED