Sha256: e1d2159ce805e381f7a31b460f9eac941e13a7c9fe2d8832c8d488ac65c10b6f
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
#!/usr/bin/env ruby def unquote(line) if line line.match(/["'](.*)["']/) $1 end end def find_project_root current = Dir.pwd until (File.exists? 'Capfile') Dir.chdir '..' return nil if current == Dir.pwd current = Dir.pwd end current end begin stage = ARGV.shift remote_command = ARGV.join(' ').strip find_project_root or raise 'Call me from inside a Rails project!' data = if stage deploy_file = Dir['config/deploy/*.rb'].find do |file| file.match(/\/#{stage}.rb$/) end deploy_file or raise "Unknown stage: #{stage}" File.open(deploy_file).readlines else [] end + File.open("config/deploy.rb").readlines user = unquote data.find{ |line| line =~ /^set :user, /} server = unquote data.find{ |line| line =~ /^server / } deploy_to = unquote data.find{ |line| line =~ /^set :deploy_to, /} (user and server and deploy_to) or raise "Could not find required data (user, server and deploy-target).\nUsage: shell-for DEPLOYMENT_STAGE" path = deploy_to + "/current" ssh = %(ssh #{user}@#{server}) if path.match /#\{.*\}/ puts %(NOTE: "#{path}" is not a valid path.) puts %(NOTE: Connecting to deploy user home.) puts sleep 2 exec ssh else command = remote_command.empty? ? "bash --login" : remote_command exec ssh + %( -t "cd #{path} && #{command}") end rescue Exception => e $stderr.puts e.message exit 1 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geordi-0.4.0 | bin/shell-for |