Sha256: 75af32fdf9e1f2af3a06ae3e4d551f5594a4b11a38f09b1ea8c19fdd4ad769ad
Contents?: true
Size: 1.52 KB
Versions: 4
Compression:
Stored size: 1.52 KB
Contents
#!/usr/bin/env ruby FREIGHTHOP_VARGANT_DOTFILE_PATH = File.expand_path('~/.freighthop.d/vagrant') FREIGHTHOP_VARGANT_CWD = File.expand_path(File.dirname(__FILE__)) unless File.directory?(FREIGHTHOP_VARGANT_DOTFILE_PATH) require 'fileutils' FileUtils.mkdir_p(FREIGHTHOP_VARGANT_DOTFILE_PATH) end ENV['VAGRANT_DOTFILE_PATH'] = FREIGHTHOP_VARGANT_DOTFILE_PATH ENV['VAGRANT_CWD'] = FREIGHTHOP_VARGANT_CWD PROJECT_NAME = File.basename(Dir.pwd) PROJECT_DIR = "/srv/#{PROJECT_NAME}" def vagrant_ssh(cmd) %Q(/usr/bin/vagrant ssh -c 'sudo /bin/bash -l -c "cd #{PROJECT_DIR}; #{cmd}"') end def console_command if File.exist?('./bin/rails') './bin/rails console' elsif File.exist?('./script/console') './script/console' else './script/rails console' end end subcommand, *rest = ARGV case subcommand when 'run' then `vagrant ssh-config > /tmp/freighthop.ssh-config` exec %Q(ssh -t -F /tmp/freighthop.ssh-config #{PROJECT_NAME} 'cd #{PROJECT_DIR}; sudo /bin/bash -l -c "#{rest.join(' ')}"') when 'console' then `vagrant ssh-config > /tmp/freighthop.ssh-config` exec %Q(ssh -t -F /tmp/freighthop.ssh-config #{PROJECT_NAME} 'sudo /bin/bash -l -c "cd #{PROJECT_DIR}; #{console_command} #{rest.join(' ')}"') when 'rake' then exec vagrant_ssh("bundle exec rake #{rest.join(' ')}") when 'ssh' then `vagrant ssh-config > /tmp/freighthop.ssh-config` exec %Q(ssh -t -F /tmp/freighthop.ssh-config #{PROJECT_NAME} 'cd #{PROJECT_DIR}; sudo /bin/bash -l -i') else exec "/usr/bin/vagrant #{ARGV.join(' ')}" end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
freighthop-0.0.5 | bin/fh |
freighthop-0.0.4 | bin/fh |
freighthop-0.0.3 | bin/fh |
freighthop-0.0.2 | bin/fh |