diff options
author | elijah <elijah@riseup.net> | 2012-11-28 01:40:20 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2012-11-28 01:40:20 -0800 |
commit | c76221182ca98ed804cc0c5259982250fa45f67c (patch) | |
tree | cdc3385f04eadc793274c4943e21fe419b406ccb /lib/leap_cli/remote/plugin.rb | |
parent | c91b94d10ae5540c5d4128f8ca8748bd897f2cfb (diff) |
give the user a nice error if 'init-node' has not yet been run (or if there are required packages that are missing).
Diffstat (limited to 'lib/leap_cli/remote/plugin.rb')
-rw-r--r-- | lib/leap_cli/remote/plugin.rb | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/lib/leap_cli/remote/plugin.rb b/lib/leap_cli/remote/plugin.rb index a69cca4..6dafbd8 100644 --- a/lib/leap_cli/remote/plugin.rb +++ b/lib/leap_cli/remote/plugin.rb @@ -4,18 +4,49 @@ module LeapCli; module Remote; module Plugin + def required_packages + "puppet ruby-hiera-puppet rsync lsb-release" + end + def log(*args, &block) LeapCli::Util::log(*args, &block) end - def mkdir(dir) - run "mkdir -p #{dir}" + # + # creates directories that are owned by root and 700 permissions + # + def mkdirs(*dirs) + raise ArgumentError.new('illegal dir name') if dirs.grep(/[\' ]/).any? + run dirs.collect{|dir| "mkdir -m 700 -p #{dir}; "}.join end - def chown_root(dir) - run "chown root -R #{dir} && chmod -R ag-rwx,u+rwX #{dir}" + def assert_initialized + + begin + test_initialized_file = "test -f /srv/leap/initialized" + check_required_packages = "! dpkg-query -W --showformat='${Status}\n' #{required_packages} 2>&1 | grep -q -E '(deinstall|no packages)'" + run "#{test_initialized_file} && #{check_required_packages}" + rescue Capistrano::CommandError => exc + LeapCli::Util.bail! do + exc.hosts.each do |host| + LeapCli::Util.log :error, "running deploy: node not initialized. Run 'leap init-node #{host}'", :host => host + end + end + end end + def mark_initialized + run "touch /srv/leap/initialized" + end + + #def mkdir(dir) + # run "mkdir -p #{dir}" + #end + + #def chown_root(dir) + # run "chown root -R #{dir} && chmod -R ag-rwx,u+rwX #{dir}" + #end + # # takes a block, yielded a server, that should return {:source => '', :dest => ''} # |