Created
June 4, 2009 19:42
-
-
Save wallace/123800 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/sh -e | |
| # this script insures that on boot we have the latest version of the application deployed to this instance | |
| # this must be run after the ec2-init script which sets the hostname. ec2-init is currently S90 | |
| if [ -e /var/spool/ec2/meta-data/public-hostname ]; then | |
| touch /root/aa_my_hostname.$$ | |
| MY_HOSTNAME=`cat /var/spool/ec2/meta-data/public-hostname` | |
| else | |
| touch /root/aa_no_my_hostname.$$ | |
| exit 1 | |
| fi | |
| # configure ssh to use the appropriate public key for the public DNS name of | |
| # this instance so that this instance can deploy to itself | |
| touch /root/ab_check_ssh_config.$$ | |
| SSH_TEMP_FILE=.rollbook_init.$$ | |
| grep ${MY_HOSTNAME} /home/rbadmin/.ssh/config > ${SSH_TEMP_FILE} | |
| if [ ! -s ${SSH_TEMP_FILE} ]; then | |
| touch /root/ac_echo_check_ssh_config.$$ | |
| echo "Host ${MY_HOSTNAME}\n IdentityFile ~/.ssh/rollbook" >> /home/rbadmin/.ssh/config | |
| fi | |
| rm ${SSH_TEMP_FILE} | |
| # runs a set of commands as rbadmin | |
| # 1. clones the repos to get the lastest cap file iff /var/www/rails/rollbook/current symlink doesn't exist (implies first boot of this instance) | |
| # 2. cds into rbadmin home dir, runs production deploy:setup, runs production deploy | |
| # 3. cleans up initial clone in step 1 if necessary | |
| touch /root/ad_rbk.$$ | |
| RBK_TEMP_DIR=.rollbook.$$.boot | |
| if [ ! -h /var/www/rails/rollbook/current ]; then | |
| touch /root/ae_rbk_rm_rf.$$ | |
| rm -rf /home/rbadmin/${RBK_TEMP_DIR} # git cannot clone to an already existing directory | |
| touch /root/af_rbk_git_clone.$$ | |
| git clone --depth 1 ssh://[email protected]/store/git/rollbook/.git /home/rbadmin/${RBK_TEMP_DIR} | |
| touch /root/ag_rbk_cap_stuff.$$ | |
| cd /home/rbadmin/${RBK_TEMP_DIR} && cap HOSTS=${MY_HOSTNAME} production deploy:setup && cap HOSTS=${MY_HOSTNAME} production deploy | |
| touch /root/ah_rbk_clean_up.$$ | |
| rm -rf /home/rbadmin/${RBK_TEMP_DIR} | |
| touch /root/ai_rbk_clean_up.$$ | |
| chmod -R rbadmin:rbadmin /var/www/rails/rollbook | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment