Sha256: eeee7dcbcf18211d7f4bb9c820b5461a095801d75a168c451b2df615299263a7

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

#!/usr/bin/env ruby

require 'kiosk'
require 'json'

def gem_dir
  ServiceKiosk::Kiosk.gem_dir
end

def config
  file = File.read('Kioskfile.json')
  JSON.parse file
end

def vagrant_exec(command)
  exec "env KIOSK_GEM_DIR=#{gem_dir} #{command}"
end

case ARGV[0] 
when 'plaza:init', 'init'
  boxes = `env KIOSK_GEM_DIR=#{gem_dir} vagrant box list`
  if(/precise32/m.match boxes)
    puts 'plaza already initialized'
  else
    vagrant_exec 'vagrant init precise32 http://files.vagrantup.com/precise32.box'
  end

when 'plaza:up', 'up'
  vagrant_exec "vagrant up"

when 'plaza:down', 'down'
  vagrant_exec "vagrant destroy"

when 'plaza:ssh', 'ssh'
  vagrant_exec 'vagrant ssh'

when 'mall:open', 'open'
  vagrant_exec "vagrant ssh -c 'cd /vagrant/mall; /usr/local/bin/rake kiosk:start'"

when 'mall:close', 'close'
  vagrant_exec "vagrant ssh -c 'cd /vagrant/mall; /usr/local/bin/rake kiosk:stop'"

when 'mall:log', 'log'
  vagrant_exec "vagrant ssh -c 'cd /vagrant/mall; /usr/local/bin/rake kiosk:log'"

when 'kiosk:run', 'run'
  env = config['kiosks'][ARGV[1]]['env']
  mall = gem_dir + "/lib/mall.rb"
  dir = Dir.pwd + '/kiosks/' + ARGV[1]
  puts "env: #{env.inspect}"
  puts "mall: #{mall}"
  puts "dir: #{dir}"
  jruby = `which jruby`.strip
  exec(env, "#{jruby} #{mall}", :chdir => dir, :unsetenv_others => true)

else
  puts "Usage: $0 {plaza:init|plaza:up|plaza:down|plaza:ssh|mall:open|mall:close|mall:log}"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
service_kiosk-0.5.3 bin/kiosk