Class: DEIS::Upgrade
- Includes:
- Thor::Shell
- Defined in:
- lib/rdeis/upgrade.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#deploy_to ⇒ Object
Returns the value of attribute deploy_to.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#ssh ⇒ Object
Returns the value of attribute ssh.
-
#token ⇒ Object
Returns the value of attribute token.
Attributes inherited from Base
#cluster, #environment, #output, #path, #verbose
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(options, previous = nil) ⇒ Upgrade
constructor
A new instance of Upgrade.
Methods inherited from Base
#local_profile, #local_shell, #local_shell_env_include, #log, #remote_profile, #run
Constructor Details
#initialize(options, previous = nil) ⇒ Upgrade
Returns a new instance of Upgrade.
7 8 9 10 11 12 13 14 |
# File 'lib/rdeis/upgrade.rb', line 7 def initialize(, previous=nil) @repo = DEIS::Git.name @verbose = [:verbose] @environment = [:environment] @proxy = if ! ["proxy"].nil? then ["proxy"] elsif ! ENV['RDEIS_PROXY'].nil? then ENV['RDEIS_PROXY'] else nil end @ssh = SSH.new({:host => @proxy, :user => nil}) if ! @proxy.nil? @previous = if previous.nil? then DEIS::LAST_VERSION else previous end end |
Instance Attribute Details
#deploy_to ⇒ Object
Returns the value of attribute deploy_to.
5 6 7 |
# File 'lib/rdeis/upgrade.rb', line 5 def deploy_to @deploy_to end |
#proxy ⇒ Object
Returns the value of attribute proxy.
5 6 7 |
# File 'lib/rdeis/upgrade.rb', line 5 def proxy @proxy end |
#ssh ⇒ Object
Returns the value of attribute ssh.
5 6 7 |
# File 'lib/rdeis/upgrade.rb', line 5 def ssh @ssh end |
#token ⇒ Object
Returns the value of attribute token.
5 6 7 |
# File 'lib/rdeis/upgrade.rb', line 5 def token @token end |
Instance Method Details
#all ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rdeis/upgrade.rb', line 18 def all # check for current version previous_version = DEIS::Storage::BASE_PATH.gsub(DEIS::VERSION, @previous) local_prev = previous_version.gsub("$HOME", ENV['HOME']) current_version = DEIS::Storage::BASE_PATH local_curr = current_version.gsub("$HOME", ENV['HOME']) # local # if no found, look for previous version if ! File.directory?(local_curr) && File.directory?(local_prev) say("Found previous version config files locally, migrating..", :green) `mv -f #{local_prev} #{local_curr}` # find local profile content = File.open(self.local_profile, "r"){|f| f.read } File.open(self.local_profile, "w"){|f| f.write(content.gsub(previous_version, current_version)) } end # remote remote_current = run("ls -lart #{current_version} 2> /dev/null | wc -l").to_i remote_previous = run("ls -lart #{previous_version} 2> /dev/null | wc -l").to_i if remote_current == 0 && remote_previous > 1 say("Found previous remote version, migration..", :green) run("mv -f #{previous_version} #{current_version}") # replace profile run("cat #{self.remote_profile} | sed -E 's##{previous_version.gsub("$", "\\\$")}##{current_version.gsub("$", "\\\$")}#' > #{self.remote_profile}.new && mv #{self.remote_profile} #{self.remote_profile}.bk && mv #{self.remote_profile}.new #{self.remote_profile}") end end |