Created
May 10, 2015 00:36
-
-
Save framp/834f542d74e5b1640ed2 to your computer and use it in GitHub Desktop.
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
useradd -mrU git | |
mkdir /home/git/.ssh | |
chmod 700 /home/git/.ssh | |
cp /root/.ssh/authorized_keys /home/git/.ssh | |
chmod 600 .ssh/authorized_keys | |
chsh -s /usr/bin/git-shell git | |
mkdir /home/git/apps.git | |
cd /home/git/apps.git | |
git init --bare | |
export DEPLOYDIR=/location/of/your/stuff | |
export COMMAND="command --to run on your repo" | |
cat >/home/git/apps.git/hooks/post-receive <<EOL | |
#!/bin/sh | |
# | |
## store the arguments given to the script | |
read oldrev newrev refname | |
## Where to store the log information about the updates | |
LOGFILE=./post-receive.log | |
# The deployed directory (the running site) | |
DEPLOYDIR=$DEPLOYDIR | |
## Record the fact that the push has been received | |
echo -e "Received Push Request at \$( date +%F )" >> \$LOGFILE | |
echo " - Old SHA: \$oldrev New SHA: \$newrev Branch Name: \$refname" >> \$LOGFILE | |
## Update the deployed copy | |
echo "Starting Deploy" >> \$LOGFILE | |
echo " - Starting code update" | |
GIT_WORK_TREE="\$DEPLOYDIR" git checkout -f | |
echo " - Finished code update" | |
echo " - Starting build" | |
$COMMAND | |
echo " - Finished build" | |
echo "Finished Deploy" >> \$LOGFILE | |
EOL | |
chmod +x /home/git/apps.git/hooks/post-receive | |
chown git:git -R /home/git/apps.git/ /home/git/.ssh $DEPLOYDIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment