cap-strap 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of cap-strap might be problematic. Click here for more details.

@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "cap-strap"
6
- s.version = "0.1.1"
6
+ s.version = "0.1.2"
7
7
  s.authors = ["Shaun Dern"]
8
8
  s.email = ["shaun@substantial.com"]
9
9
  s.homepage = "http://github.com/substantial/cap-strap"
@@ -1,3 +1,5 @@
1
+ RVM_PATH = '/usr/local/rvm/bin/rvm'
2
+
1
3
  def _cset(name, *args, &block)
2
4
  unless exists?(name)
3
5
  set(name, *args, &block)
@@ -5,14 +7,14 @@ def _cset(name, *args, &block)
5
7
  end
6
8
 
7
9
  def add_user_to_group(user, group)
8
- sudo "usermod -a -G #{group} #{user}"
10
+ run "#{sudo} usermod -a -G #{group} #{user}"
9
11
  end
10
12
 
11
13
  def install_packages(packages)
12
14
  unless packages.empty?
13
- sudo "apt-get update"
15
+ run "#{sudo} apt-get update"
14
16
  packages.each do |pkg|
15
- sudo "apt-get -y install #{pkg}"
17
+ run "#{sudo} apt-get -y install #{pkg}"
16
18
  end
17
19
  end
18
20
  end
@@ -22,23 +24,23 @@ def create_user(user, password)
22
24
  command = "useradd -s /bin/bash -d /home/#{user}"
23
25
  command << " -p `perl -e 'print crypt(#{password}, salt)'`" if password
24
26
  command << " -m #{user}"
25
- sudo command
27
+ run "#{sudo} #{command}"
26
28
  end
27
29
  end
28
30
 
29
31
  def add_group_to_sudoers(group)
30
32
  unless group_has_sudo?(group)
31
33
  puts "********* Adding #{group} to sudoers"
32
- sudo "cp /etc/sudoers /etc/sudoers.bak"
33
- sudo "chmod a+w /etc/sudoers.bak"
34
- sudo "echo %rvm ALL=NOPASSWD:ALL >> /etc/sudoers.bak"
35
- sudo "chmod a-w /etc/sudoers.bak"
36
- sudo "mv /etc/sudoers.bak /etc/sudoers"
34
+ run "#{sudo} cp /etc/sudoers /etc/sudoers.bak"
35
+ run "#{sudo} chmod a+w /etc/sudoers.bak"
36
+ run "#{sudo} echo %rvm ALL=NOPASSWD:ALL >> /etc/sudoers.bak"
37
+ run "#{sudo} chmod a-w /etc/sudoers.bak"
38
+ run "#{sudo} mv /etc/sudoers.bak /etc/sudoers"
37
39
  end
38
40
  end
39
41
 
40
42
  def group_has_sudo?(group)
41
- sudoer_test = "sudo bash -c \"if grep -Fxq '%#{group} ALL=NOPASSWD:ALL' /etc/sudoers; then echo 'true'; else echo 'false'; fi\""
43
+ sudoer_test = "#{sudo} bash -c \"if grep -Fxq '%#{group} ALL=NOPASSWD:ALL' /etc/sudoers; then echo 'true'; else echo 'false'; fi\""
42
44
  return capture(sudoer_test).include?("true")
43
45
  end
44
46
 
@@ -55,19 +57,19 @@ end
55
57
 
56
58
  def ruby_installed?(ruby)
57
59
  ruby_test = "source /etc/profile.d/rvm.sh && if rvm list | grep -q '#{ruby} '; then echo 'true'; else echo 'false'; fi"
58
- return capture(rvm_wrapper(ruby_test)).include?("true")
60
+ return capture(ruby_test).include?("true")
59
61
  end
60
62
 
61
63
  def install_ruby(ruby, patch = nil)
62
64
  unless ruby_installed?(ruby)
63
- command = "/usr/local/rvm/bin/rvm install #{ruby}"
65
+ command = "#{RVM_PATH} install #{ruby}"
64
66
  command << " --patch #{patch}" if patch
65
- sudo command
67
+ run "#{sudo} #{command}"
66
68
  end
67
69
  end
68
70
 
69
71
  def install_global_gem(ruby, gem)
70
- sudo rvm_wrapper("rvm use #{ruby}@global --create && gem install #{gem} --no-rdoc --no-ri")
72
+ run "#{sudo} #{RVM_PATH} #{ruby}@global --create do gem install #{gem} --no-rdoc --no-ri"
71
73
  end
72
74
 
73
75
  def rvm_wrapper(command)
@@ -90,8 +92,9 @@ TEXT
90
92
  end
91
93
 
92
94
  def make_directory(location, opts={})
93
- sudo "mkdir -p #{location}"
95
+ run "#{sudo} mkdir -p #{location}"
94
96
  if opts[:mode]
95
- sudo "chmod #{opts[:mode]} #{location}"
97
+ run "#{sudo} chmod #{opts[:mode]} #{location}"
96
98
  end
97
99
  end
100
+
@@ -20,6 +20,8 @@ module Capistrano::CapStrap
20
20
  _cset(:bootstrap_password) { Capistrano::CLI.ui.ask("bootstrap root user password: ") }
21
21
  _cset(:known_hosts) { default_known_hosts }
22
22
  _cset(:packages) { [] }
23
+ _cset :authorized_keys_file, ""
24
+ _cset :deploy_key_file, ""
23
25
 
24
26
  set (:user) { bootstrap_user }
25
27
  set (:password) { bootstrap_password }
@@ -6,9 +6,9 @@ module Capistrano::CapStrap
6
6
  def self.load_into(configuration)
7
7
  configuration.load do
8
8
 
9
- _cset :default_ruby , "1.9.3-p125"
9
+ _cset :default_ruby , "1.9.3"
10
10
  _cset :gemset, "global"
11
- _cset :rubies, ["1.9.3-p125"]
11
+ _cset :rubies, ["1.9.3"]
12
12
  _cset(:user) { Capistrano::CLI.ui.ask("bootstrap root user: ") }
13
13
  _cset :global_gems, ["bundler"]
14
14
 
@@ -26,8 +26,7 @@ module Capistrano::CapStrap
26
26
  end
27
27
 
28
28
  task :install_system_wide_rvm do
29
- command = "curl -L get.rvm.io | "
30
- command << "sudo bash -s stable"
29
+ command = "curl -L https://get.rvm.io | #{sudo} bash -s stable"
31
30
  run command
32
31
  end
33
32
 
@@ -48,11 +47,11 @@ module Capistrano::CapStrap
48
47
  end
49
48
 
50
49
  task :create_default_gemset do
51
- sudo rvm_wrapper("rvm use #{default_ruby}@#{gemset} --create")
50
+ run "#{sudo} #{RVM_PATH} use #{default_ruby}@#{gemset} --create"
52
51
  end
53
52
 
54
53
  task :set_default_ruby do
55
- sudo rvm_wrapper("rvm use #{default_ruby} --default")
54
+ run "#{sudo} #{RVM_PATH} use #{default_ruby} --default"
56
55
  end
57
56
 
58
57
  task :add_user_to_rvm_group do
@@ -61,7 +60,7 @@ module Capistrano::CapStrap
61
60
 
62
61
  task :add_gemrc do
63
62
  put gemrc, "gemrc"
64
- sudo "mv ~/gemrc /etc/"
63
+ run "#{sudo} mv ~/gemrc /etc/"
65
64
  end
66
65
  end
67
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cap-strap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-02 00:00:00.000000000 Z
12
+ date: 2012-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -178,12 +178,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
178
178
  - - ! '>='
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
+ segments:
182
+ - 0
183
+ hash: 3071073874735159760
181
184
  required_rubygems_version: !ruby/object:Gem::Requirement
182
185
  none: false
183
186
  requirements:
184
187
  - - ! '>='
185
188
  - !ruby/object:Gem::Version
186
189
  version: '0'
190
+ segments:
191
+ - 0
192
+ hash: 3071073874735159760
187
193
  requirements: []
188
194
  rubyforge_project: cap-strap
189
195
  rubygems_version: 1.8.24