standup 0.5.1 → 0.5.3

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.
@@ -73,10 +73,40 @@ module Standup
73
73
  with_context(:prefix => prefix, &block)
74
74
  end
75
75
 
76
+ def raw_exec command
77
+ bright_p command
78
+
79
+ result = ''
80
+
81
+ collect_output = lambda do |data|
82
+ result << data
83
+ print(data)
84
+ STDOUT.flush
85
+ end
86
+
87
+ main_channel = ssh.open_channel do |ch|
88
+ ch.exec("bash -l") do |ch2, _|
89
+ ch2.on_data { |_, data| collect_output.call(data) }
90
+
91
+ ch2.on_extended_data { |_, _, data| collect_output.call(data) }
92
+
93
+ ch2.send_data "export TERM=vt100\n"
94
+
95
+ ch2.send_data "#{command}\n"
96
+
97
+ ch2.send_data "exit\n"
98
+ end
99
+ end
100
+
101
+ main_channel.wait
102
+
103
+ result
104
+ end
105
+
76
106
  def exec command, context = @context
77
107
  command = "#{context[:prefix].strip} #{command}" if context[:prefix].present?
78
108
  command = "cd #{context[:path]} && #{command}" if context[:path].present?
79
- command = "/usr/local/rvm/bin/rvm-shell -c \"#{command}\"" if rvm_installed?
109
+ command = "#{shell_command} -c \"#{command.gsub(/"/, '\"')}\""
80
110
 
81
111
  if context[:user].present?
82
112
  command = "sudo -u #{context[:user]} #{command}"
@@ -84,15 +114,13 @@ module Standup
84
114
  command = "sudo #{command}"
85
115
  end
86
116
 
87
- bright_p command
88
- ssh.exec! command do |ch, _, data|
89
- ch[:result] ||= ""
90
- ch[:result] << data
91
- print data
92
- STDOUT.flush
93
- end
117
+ raw_exec command
94
118
  end
95
-
119
+
120
+ def shell_command
121
+ rvm_installed? ? 'rvm-shell' : 'bash'
122
+ end
123
+
96
124
  def sudo command = nil, &block
97
125
  block = Proc.new { exec command } unless block_given?
98
126
  with_context(:sudo => true, &block)
@@ -112,10 +140,10 @@ module Standup
112
140
  result
113
141
  end
114
142
 
115
- def file_exists? path
116
- exec("if [ -e #{path} ]; then echo 'true'; fi") == "true\n"
143
+ def file_exists? path, raw = false
144
+ send(:"#{raw ? 'raw_' : ''}exec", "if [ -e #{path} ]; then echo 'true'; fi") == "true\n"
117
145
  end
118
-
146
+
119
147
  def install_packages packages, opts = {}
120
148
  input = opts[:input] ? "echo \"#{opts[:input].join("\n")}\" | sudo " : ''
121
149
  sudo "#{input}apt-get -qqy install #{packages}"
@@ -157,7 +185,10 @@ module Standup
157
185
  end
158
186
 
159
187
  def rvm_installed?
160
- @rvm_installed ||= ssh.exec!("if [ -e /usr/local/rvm/bin/rvm ]; then echo 'true'; fi") == "true\n"
188
+ unless instance_variable_defined? :@rvm_installed
189
+ @rvm_installed = file_exists?('/usr/local/rvm/bin/rvm', true)
190
+ end
191
+ @rvm_installed
161
192
  end
162
193
 
163
194
  protected
@@ -166,7 +197,8 @@ module Standup
166
197
  @ssh ||= Net::SSH.start @host, @user,
167
198
  :keys => @keypair_file,
168
199
  :paranoid => false,
169
- :timeout => 10
200
+ :timeout => 10,
201
+ :compression => 'zlib'
170
202
  end
171
203
 
172
204
  def rsync source, destination, sudo
@@ -1,5 +1,5 @@
1
1
  module Standup
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.3"
3
3
 
4
4
  def self.version
5
5
  VERSION
data/scripts/db_backup.rb CHANGED
@@ -1,4 +1,4 @@
1
- Standup.script :node do
1
+ klnblkblkbklblkcdStandup.script :node do
2
2
  def run
3
3
  exec "s3cmd mb #{bucket}"
4
4
 
@@ -12,6 +12,9 @@ ec2:
12
12
  instance_type: m1.small
13
13
  ssh_user: ubuntu
14
14
 
15
+ shell:
16
+ extra_options: -L 5433:localhost:5432
17
+
15
18
  webapp:
16
19
  name:
17
20
  github_user:
data/scripts/ruby.rb CHANGED
@@ -1,17 +1,19 @@
1
1
  Standup.script :node do
2
2
  def run
3
- return if remoting.rvm_installed?
4
-
5
- install_package 'git-core'
6
-
7
- sudo 'bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)'
8
-
9
- exec "rvm install #{version}"
10
- exec "rvm use #{version} --default"
11
-
12
- sudo 'usermod -a -G rvm www-data'
13
-
14
- remoting.instance_variable_set :@rvm_installed, true
3
+ unless remoting.rvm_installed?
4
+ install_package 'git-core'
5
+ sudo 'bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)'
6
+ sudo 'usermod -a -G rvm www-data'
7
+ exec 'source /usr/local/rvm/scripts/rvm'
8
+ remoting.instance_variable_set :@rvm_installed, true
9
+ end
10
+
11
+ unless exec('rvm list')[version]
12
+ install_packages 'build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev'
13
+
14
+ sudo "rvm install #{version}"
15
+ exec "rvm use #{version} --default"
16
+ end
15
17
  end
16
18
 
17
19
  def version
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: standup
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.1
5
+ version: 0.5.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ilia Ablamonov
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2011-07-04 00:00:00 +04:00
15
+ date: 2011-07-06 00:00:00 +04:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency