Skip to content

Instantly share code, notes, and snippets.

@chriskief
Created October 24, 2013 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriskief/7130782 to your computer and use it in GitHub Desktop.
Save chriskief/7130782 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
# switch to the attachment directory
cd $RS_ATTACH_DIR
# move the sync script
mv sync.sh /home/rightscale/.ssh/sync.sh
# make script executable
chmod u+x /home/rightscale/.ssh/sync.sh
# create temporary SSH key
cat > "/home/rightscale/.ssh/id_rsa" << EOF
$GIT_SSH_KEY
EOF
# chmod to 600
chmod 600 /home/rightscale/.ssh/id_rsa
# set GIT_SSH
export GIT_SSH=/home/rightscale/.ssh/sync.sh
# clone the repo
git clone --depth 1 git@bitbucket.org:myrepo/reponame.git /home/rightscale/$APPLICATION
# recompress assets
python /home/webapps/$APPLICATION/manage.py collectstatic --noinput -i css -i js
python /home/webapps/$APPLICATION/manage.py compress
# stop apache
service apache2 stop
# remove the current app directory
rm -rf /home/webapps/$APPLICATION
# move the new app directory into place
mv /home/rightscale/$APPLICATION /home/webapps/$APPLICATION
# restart apache
service apache2 start
# remove temporary SSH key
rm /home/rightscale/.ssh/id_rsa
rm /home/rightscale/.ssh/sync.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment