lib/smartcloud/engine.rb in smartcloud-0.2.0.beta2 vs lib/smartcloud/engine.rb in smartcloud-0.2.0

- old
+ new

@@ -2,33 +2,45 @@ module Smartcloud class Engine < Smartcloud::Base def initialize end - def self.install + def install + self.uninstall + + Smartcloud::User.create_htpasswd_files + ssh = Smartcloud::SSH.new machine = Smartcloud::Machine.new system("mkdir -p ./tmp/engine") system("cp #{Smartcloud.config.root_path}/lib/smartcloud/engine/Dockerfile ./tmp/engine/Dockerfile") + gem_file_path = File.expand_path("../../cache/smartcloud-#{Smartcloud.version}.gem", Smartcloud.config.root_path) + system("cp #{gem_file_path} ./tmp/engine/smartcloud-#{Smartcloud.version}.gem") + machine.sync first_sync: true puts "-----> Creating image smartcloud ... " ssh.run "docker image build -t smartcloud \ - --build-arg DOCKER_GID=`getent group docker | cut -d: -f3` \ - --build-arg USER_UID=`id -u` \ + --build-arg SMARTCLOUD_MASTER_KEY=#{Smartcloud::Credentials.new.read_key} \ + --build-arg SMARTCLOUD_VERSION=#{Smartcloud.version} \ --build-arg USER_NAME=`id -un` \ + --build-arg USER_UID=`id -u` \ + --build-arg DOCKER_GID=`getent group docker | cut -d: -f3` \ ~/.smartcloud/tmp/engine" puts "-----> Adding smartcloud to PATH ... " ssh.run "chmod +x ~/.smartcloud/bin/smartcloud.sh && sudo ln -sf ~/.smartcloud/bin/smartcloud.sh /usr/local/bin/smartcloud" system("rm ./tmp/engine/Dockerfile") + system("rm ./tmp/engine/smartcloud-#{Smartcloud.version}.gem") machine.sync end - def self.uninstall + def uninstall + ssh = Smartcloud::SSH.new + ssh.run "sudo rm /usr/local/bin/smartcloud" ssh.run "docker rmi smartcloud" end end end