sshkit-sudo 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -5
- data/lib/sshkit/sudo.rb +1 -0
- data/lib/sshkit/sudo/backends_ext/local.rb +2 -2
- data/lib/sshkit/sudo/backends_ext/netssh.rb +7 -7
- data/lib/sshkit/sudo/backends_ext/printer.rb +2 -2
- data/lib/sshkit/sudo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e291e2bf21a00303927c5a59591e32ac2b5b458
|
4
|
+
data.tar.gz: 33de5ccdce8b57c26bd7c52437c259933b127d09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4607e9f353e2a5b5d739a4aaa5af0d439bc29d1b70e89b6f866ac6a3c0aeed505733c4cd5d82966ff0743cb0eb3cdefb8ed1be1ad94edab3a4afa5ecee29a6d7
|
7
|
+
data.tar.gz: 84a0ea8902c563f9ee875bc8df588b590b9e690988f91b5ab4536f62cc966cfdff44de173cbcd3127902a049ec7a1646ad353acdf1875a02ab0f05b265f0787e
|
data/README.md
CHANGED
@@ -22,16 +22,55 @@ require 'sshkit/sudo'
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
This gem adds `sudo` command to SSHKit backends.
|
25
|
+
This gem adds `sudo` and `execute!` command to SSHKit backends.
|
26
26
|
|
27
27
|
To execute a command with sudo, call `sudo` instead of `execute`.
|
28
28
|
|
29
|
+
```ruby
|
30
|
+
sudo :cp, '~/something', '/something'
|
31
|
+
|
32
|
+
# Or as follows:
|
33
|
+
execute! :sudo, :cp, '~/something', '/something'
|
34
|
+
```
|
35
|
+
|
36
|
+
### Examples in Capistrano tasks
|
37
|
+
|
29
38
|
```ruby
|
30
39
|
# Executing a command with sudo in Capistrano task
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
40
|
+
namespace :nginx do
|
41
|
+
desc 'Reload nginx'
|
42
|
+
task :reload do
|
43
|
+
on roles(:web), in: :sequence do
|
44
|
+
sudo :service, :nginx, :reload
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'Restart nginx'
|
49
|
+
task :restart do
|
50
|
+
on roles(:web), in: :sequence do
|
51
|
+
execute! :sudo, :service, :nginx, :restart
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
namespace :prov do
|
57
|
+
desc 'Install nginx'
|
58
|
+
task :nginx do
|
59
|
+
on roles(:web), in: :sequence do
|
60
|
+
|
61
|
+
within '/etc/apt' do
|
62
|
+
unless test :grep, '-Fxq', '"deb http://nginx.org/packages/debian/ wheezy nginx"', 'sources.list'
|
63
|
+
execute! :echo, '"deb http://nginx.org/packages/debian/ wheezy nginx"', '|', 'sudo tee -a sources.list'
|
64
|
+
execute! :echo, '"deb-src http://nginx.org/packages/debian/ wheezy nginx"', '|', 'sudo tee -a sources.list'
|
65
|
+
|
66
|
+
execute! :wget, '-q0 - http://nginx.org/keys/nginx_signing.key', '|', 'sudo apt-key add -'
|
67
|
+
|
68
|
+
sudo :'apt-get', :update
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
sudo :'apt-get', '-y install nginx'
|
73
|
+
end
|
35
74
|
end
|
36
75
|
end
|
37
76
|
```
|
data/lib/sshkit/sudo.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
# require 'net/ssh'
|
2
|
-
require 'sshkit'
|
3
|
-
# require 'sshkit/backend/netssh'
|
4
|
-
|
5
1
|
module SSHKit
|
6
2
|
module Backend
|
7
3
|
|
8
4
|
class Netssh < Printer
|
9
5
|
def sudo(*args)
|
10
|
-
|
6
|
+
_execute!(:sudo, *args).success?
|
7
|
+
end
|
8
|
+
|
9
|
+
def execute!(*args)
|
10
|
+
_execute!(*args).success?
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
-
def
|
16
|
-
command(
|
15
|
+
def _execute!(*args)
|
16
|
+
command(*args).tap do |cmd|
|
17
17
|
output << cmd
|
18
18
|
cmd.started = true
|
19
19
|
exit_status = nil
|
data/lib/sshkit/sudo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sshkit-sudo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaro Imai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sshkit
|