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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4aef500f984bbbcac5a81ea14dcae23d3cd909ef
4
- data.tar.gz: 1b7daedbca438fb00feb770091071f6c347301ff
3
+ metadata.gz: 8e291e2bf21a00303927c5a59591e32ac2b5b458
4
+ data.tar.gz: 33de5ccdce8b57c26bd7c52437c259933b127d09
5
5
  SHA512:
6
- metadata.gz: f360bcfc138880579c22b0bfb6fcd1f82bff408c9ff878aabd2c9647ff2eca17535a17c92b0aa7243a94c50bb5bd4d9236a6ffa73866fe6ec503bebcbaee2116
7
- data.tar.gz: ba4027bd19e83afe772c00e0d0a8d55a285978c2184ffe90ea9c2a109a6b7ea1152f58f818822f08dcb9566e719e2507b630ebd46731de8302f9edf8340a57db
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
- desc 'hello'
32
- task :hello do
33
- on roles(:all) do
34
- sudo :cp, '~/something', '/something'
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
  ```
@@ -1,4 +1,5 @@
1
1
  require "sshkit/sudo/version"
2
+ require 'sshkit'
2
3
  require "sshkit/sudo/backends_ext/printer"
3
4
  require "sshkit/sudo/backends_ext/netssh"
4
5
  require "sshkit/sudo/backends_ext/local"
@@ -1,11 +1,11 @@
1
- require 'sshkit'
2
-
3
1
  module SSHKit
4
2
  module Backend
5
3
  class Local < Printer
6
4
  def sudo(*args)
7
5
  _execute(:sudo, *args).success?
8
6
  end
7
+
8
+ alias execute! execute
9
9
  end
10
10
  end
11
11
  end
@@ -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
- _sudo(*args).success?
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 _sudo(*args)
16
- command(:sudo, *args).tap do |cmd|
15
+ def _execute!(*args)
16
+ command(*args).tap do |cmd|
17
17
  output << cmd
18
18
  cmd.started = true
19
19
  exit_status = nil
@@ -1,5 +1,3 @@
1
- require 'sshkit'
2
-
3
1
  module SSHKit
4
2
  module Backend
5
3
  class Printer < Abstract
@@ -8,6 +6,8 @@ module SSHKit
8
6
  output << cmd
9
7
  end
10
8
  end
9
+
10
+ alias execute! execute
11
11
  end
12
12
  end
13
13
  end
@@ -1,5 +1,5 @@
1
1
  module SSHKit
2
2
  module Sudo
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
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.2
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-25 00:00:00.000000000 Z
11
+ date: 2015-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sshkit