Created
September 10, 2013 16:02
-
-
Save schwuk/6511613 to your computer and use it in GitHub Desktop.
Git post-receive hook for deploying/updating applications (using gitolite, make, and upstart).
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 | |
APP_NAME=foo | |
mkdir -p /srv/$APP_NAME | |
GIT_WORK_TREE=/srv/$APP_NAMEs GIT_DIR=/var/lib/git/repositories/$APP_NAME.git git reset --hard | |
sudo /bin/chown -R $APP_NAME:$APP_NAME /srv/$APP_NAME | |
sudo /bin/chmod -R g+w /srv/$APP_NAME | |
sudo /sbin/status $APP_NAME | grep "^$APP_NAME start" > /dev/null 2>&1 | |
running=$? | |
if [ $running -eq 0 ]; then | |
sudo /sbin/stop $APP_NAME | |
fi | |
cd /srv/$APP_NAME | |
sudo -u $APP_NAME /usr/bin/make deploy | |
cd - | |
sudo /sbin/start $APP_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment