libexec/aohelper in alpha_omega-1.5.6 vs libexec/aohelper in alpha_omega-1.5.7

- old
+ new

@@ -1,14 +1,30 @@ +#!/bin/bash + +shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)" + function ryaml { ruby -ryaml -e 'def ps x; unless x.nil?; puts (x.class == String || x.class == Fixnum) ? x : x.to_yaml; end; end; ps ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[acc.class == Array ? key.to_i : key] }' "$@" 2>&- } -shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)" +function main { + local app_ruby="$(ryaml $shome/config/deploy.yml app_ruby)" + local ruby_loader="$(ryaml $shome/config/deploy.yml ruby_loader)" + local ruby_runner="$ruby_loader $app_ruby" + PATH="$PATH:/usr/local/rvm/bin:$HOME/.rvm/bin" -app_ruby="$(ryaml $shome/config/deploy.yml app_ruby)" -ruby_loader="$(ryaml $shome/config/deploy.yml ruby_loader)" -PATH="$PATH:/usr/local/rvm/bin:$HOME/.rvm/bin" + if [[ "$ruby_loader" = "rvm-exec" ]]; then + local pth_rvm="$(type -f $ruby_loader 2>&- | awk '{print $3}')" + if [[ -x "$pth_rvm" ]]; then + true + else + ruby_runner="" + fi + fi -if ! $ruby_loader $app_ruby bundle check 2>&- > /dev/null; then - $ruby_loader $app_ruby bundle install --local --quiet --path vendor/bundle -fi -$ruby_loader $app_ruby bundle exec ao "${BASH_SOURCE##*/}" "$@" + if ! $ruby_runner bundle check 2>&- > /dev/null; then + $ruby_runner bundle install --local --quiet --path vendor/bundle + fi + $ruby_runner bundle exec ao "${BASH_SOURCE##*/}" "$@" +} + +main "$@"