Skip to content

Instantly share code, notes, and snippets.

@wearethefoos
Created April 16, 2015 10:33
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save wearethefoos/7348931fbcdb3bb1a21d to your computer and use it in GitHub Desktop.
Save wearethefoos/7348931fbcdb3bb1a21d to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# Rails console script that can be run on AWS Elastic Beanstalk.
#
# Run this script from the app dir (/var/app/current) as root (sudo script/aws-console)
#
set -xe
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
EB_APP_DEPLOY_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir)
EB_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user)
EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
EB_PID_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_pid_dir)
EB_LOG_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_log_dir)
. $EB_SUPPORT_DIR/envvars
. $EB_SCRIPT_DIR/use-app-ruby.sh
cd $EB_APP_DEPLOY_DIR
su -s /bin/bash -c "bundle exec rails c" $EB_APP_USER
@Ewg777
Copy link

Ewg777 commented Sep 22, 2015

It works! Very thanks!

@richardwu
Copy link

Where would I save this script on the instance?

@aaronsilverman
Copy link

the author saved it in /var/app/current/scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment