Skip to content

Instantly share code, notes, and snippets.

@nikushi
Last active December 16, 2015 15:49
Show Gist options
  • Save nikushi/5458519 to your computer and use it in GitHub Desktop.
Save nikushi/5458519 to your computer and use it in GitHub Desktop.
helper shell-script to run a ruby script on rvm enviroment
# encoding: utf-8
#!/bin/sh
#
# Usage:
#
# APP_ROOT=/usr/local/app HOME=/home/app_user ./exec script/script.rb [options]
#
usage()
{
echo "Usage:" >&2
echo " $ APP_ROOT=/usr/local/app HOME=/home/app_user ./exec script/script.rb [options]" >&2
exit 1
}
if [ -z "$APP_ROOT" -o -z "$HOME" ]; then
usage
fi
source ~/.rvm/scripts/rvm
export PATH="~/.rvm/bin:$PATH"
#rvm rvmrc trust $APP_ROOT # You have to put .rvmrc or .ruby-version in the root of $APP_ROOT
cd $APP_ROOT
exec "$@"
usage()
{
echo "Usage:" >&2
echo " $ APP_ROOT=/usr/local/app HOME=/home/app_user ./exec script/script.rb [options]" >&2
exit 1
}
if [ -z "$APP_ROOT" -o -z "$HOME" ]; then
usage
fi
source ~/.rvm/scripts/rvm
rvm rvmrc trust $APP_ROOT # You have to put .rvmrc or .ruby-version in the root of $APP_ROOT
cd $APP_ROOT
exec "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment