Created
December 2, 2011 08:55
-
-
Save troex/1422410 to your computer and use it in GitHub Desktop.
Update rails from git on commits
This file contains 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 | |
# | |
# Update rails from git on commits | |
# Author: Troex Nevelin <troex@fury.scancode.ru> | |
cd /home/alex/smartspace_development | |
if [ -f .update_in_progress ]; then | |
exit 0 # exit if in progress or error happend | |
fi | |
git pull --quiet 2>&1 > .update_in_progress | |
if [ $? -ne 0 ]; then | |
echo "ERROR auto updating development at `date`" | |
cat .update_in_progress | |
exit 1 | |
fi | |
LAST_COMMIT=`cat .last_commit` | |
CURRENT_COMMIT=`git rev-parse HEAD` | |
if [ "$LAST_COMMIT" = "$CURRENT_COMMIT" ]; then | |
rm .update_in_progress | |
#echo "nothing to update" | |
exit 0 # nothing changed | |
fi | |
# updating | |
echo "Updating `pwd` at `date`" | |
bundle exec rake db:migrate | |
/etc/init.d/unicorn.sh restart smartspace-development | |
echo $CURRENT_COMMIT > .last_commit | |
rm .update_in_progress |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment