class DEIS::Bootstrap
Attributes
deploy_to[RW]
proxy[RW]
ssh[RW]
token[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/rdeis/bootstrap.rb, line 7 def initialize(options) @repo = DEIS::Git.name @verbose = options[:verbose] @environment = options[:environment] say( "Checking local environment..", :green) end
Public Instance Methods
all()
click to toggle source
# File lib/rdeis/bootstrap.rb, line 53 def all @proxy = nil @token = nil file = DEIS::Storage::BASE_PATH.gsub("$HOME", ENV['HOME'])+".profile" if ! File.exists?(file) self.proxy @ssh = SSH.new({:host => @proxy, :user => nil}) if ! @proxy.nil? self.hush self.github_token self.deploy_path self.save @ssh.close say "Bootstrap Completed", :blue end end
deploy_path()
click to toggle source
# File lib/rdeis/bootstrap.rb, line 38 def deploy_path if @proxy.nil? @deploy_to = ask("Please enter local folder to deploy to: ", :yellow) else @deploy_to = ask("Please enter containing folder on #{@proxy} to deploy to: ", :yellow) end end
github_token()
click to toggle source
# File lib/rdeis/bootstrap.rb, line 20 def github_token # if local env doesnt have it and no proxy host, just ask if ENV[DEIS::Git.github_token_varname].nil? && @proxy.nil? @token = ask("Please enter your github auth token: ", :yellow) # if proxy is set, then check for the var on the proxy:key => "value", elsif ENV[DEIS::Git.github_token_varname].nil? && ! @proxy.nil? cmd = DEIS::Git.github_token_cmd say("[#{Time.now.to_s}] "+cmd+"\n", :black) if @verbose remote = @ssh.exec!(cmd).to_s.strip if ! remote.nil? && remote.length > 0 && (yes?("Found #{remote} on #{@proxy}, set as local version? (y/n): ", :yellow) ) @token = remote end else @token = ask("Please enter a github auth token for deployment: ", :yellow) end end
hush()
click to toggle source
add a hush login file so we dont get the MOTD ouput in our shell commands
# File lib/rdeis/bootstrap.rb, line 47 def hush if yes?("Does the deploy location run a Message of the Day? ", :yellow) run("if [[ ! -f $HOME/.hushlogin ]]; then > $HOME/.hushlogin ; fi ") end end
save()
click to toggle source
# File lib/rdeis/bootstrap.rb, line 69 def save # the base file location for the env vars we need file = DEIS::Storage::ENV_VAR_PATH replaced = DEIS::Storage::BASE_PATH.gsub("$HOME", ENV['HOME']) FileUtils.mkdir_p(replaced) if ! File.directory?(replaced) out = "# [rdeis #{DEIS::VERSION}] Auto generated at #{Time.now.to_s}\n" out = out+"export RDEIS_PROXY=\"#{@proxy}\"\n" if ! @proxy.nil? out = out+"export RDEIS_PATH=\"#{@deploy_to.gsub('$', '\$') }\"\n" if ! @deploy_to.nil? out = out+"export #{DEIS::Git.github_token_varname}=\"#{@token}\"\n" if ! @token.nil? # write locally File.open(file.gsub("$HOME", ENV['HOME']), "w"){ |f| f.write(out) } # run remote, keep the $HOME notation as we want that evaluated in the cmd run("mkdir -p #{DEIS::Storage::BASE_PATH} ; echo -e '#{out}' > #{file}") if ! @proxy.nil? # remove any existing references from the various shell options on the local machine shell = self.local_shell profile = self.local_profile if ! profile.nil? self.local_shell_env_include(profile, file) else say "Could not save environment setup", :red end # add include to the remote profile run("echo -e '. #{file}\n' >> #{self.remote_profile}") if ! @proxy.nil? end