aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-10-27 15:56:48 -0700
committerelijah <elijah@riseup.net>2012-10-27 15:56:48 -0700
commit669bf5aa6f81e0cd1d1956bee6ed26715fb896fa (patch)
tree1f2d82b28f714ce937b688f1d0814a862a6f9f8b /lib
parent20ab16c583a139ff64b83ad5450257ca1dc5924e (diff)
downloadleap_cli-669bf5aa6f81e0cd1d1956bee6ed26715fb896fa.tar.gz
leap_cli-669bf5aa6f81e0cd1d1956bee6ed26715fb896fa.tar.bz2
auto run 'git submodule update --init' on leap platform if needed
Diffstat (limited to 'lib')
-rw-r--r--lib/leap_cli/commands/deploy.rb18
-rw-r--r--lib/leap_cli/util.rb10
2 files changed, 25 insertions, 3 deletions
diff --git a/lib/leap_cli/commands/deploy.rb b/lib/leap_cli/commands/deploy.rb
index 8febe4d..31ae053 100644
--- a/lib/leap_cli/commands/deploy.rb
+++ b/lib/leap_cli/commands/deploy.rb
@@ -6,6 +6,8 @@ module LeapCli
arg_name '<node filter>'
command :deploy do |c|
c.action do |global_options,options,args|
+ init_submodules
+
nodes = manager.filter!(args)
if nodes.size > 1
say "Deploying to these nodes: #{nodes.keys.join(', ')}"
@@ -13,6 +15,7 @@ module LeapCli
quit! "OK. Bye."
end
end
+
ssh_connect(nodes) do |ssh|
# directory setup
ssh.leap.mkdir("/etc/leap")
@@ -46,5 +49,20 @@ module LeapCli
end
end
+ private
+
+ def init_submodules
+ Dir.chdir Path.platform do
+ statuses = assert_run! "git submodule status"
+ statuses.strip.split("\n").each do |status_line|
+ if status_line =~ /^-/
+ submodule = status_line.split(' ')[1]
+ progress "Updating submodule #{submodule}"
+ assert_run! "git submodule update --init #{submodule}"
+ end
+ end
+ end
+ end
+
end
end \ No newline at end of file
diff --git a/lib/leap_cli/util.rb b/lib/leap_cli/util.rb
index fdbdc8a..3b0c334 100644
--- a/lib/leap_cli/util.rb
+++ b/lib/leap_cli/util.rb
@@ -55,11 +55,15 @@ module LeapCli
# assert that the command is run without an error.
# if successful, return output.
#
- def assert_run!(cmd, message)
- log2(" * run: #{cmd}")
+ def assert_run!(cmd, message=nil)
cmd = cmd + " 2>&1"
output = `#{cmd}`
- assert!($?.success?, message)
+ unless $?.success?
+ log1(" * run: #{cmd}")
+ log1(" * FAILED: (exit #{$?}) #{output}")
+ else
+ log2(" * run: #{cmd}")
+ end
return output
end