pouet.net/bin/deploy
2013-05-12 17:07:48 -04:00

63 lines
1.5 KiB
Bash
Executable File

#!/bin/sh -e
TMP_FOLDER="/home/hosted/pouet/deploy_folder"
LIVE_FOLDER="/home/hosted/pouet/sites/www.pouet.net"
LOCAL_COMMIT_FILE="$LIVE_FOLDER/tmp/LOCAL_COMMIT"
REMOTE_COMMIT_FILE="$LIVE_FOLDER/tmp/REMOTE_COMMIT"
RSYNC="/home/hosted/pouet/bin/rsync \
--recursive \
--delete \
--progress \
--checksum \
--links\
--keep-dirlinks \
--exclude=avatars \
--exclude=gfx/logos \
--exclude=nfo \
--exclude=othernfo \
--exclude=results \
--exclude=screenshots \
--exclude=rulez/*.log \
--exclude=tmp/* \
--exclude=include/auth.php \
--exclude=.git"
# Check if an update is waiting and if another deploy is running
if [ -f $REMOTE_COMMIT_FILE ]
then
cd
if [ -d $TMP_FOLDER ]
then
# Another update is running, give up
exit 1
fi
# Let's go, create the working folder
mkdir $TMP_FOLDER
# Get the wanted hash
REMOTE_COMMIT=`cat $REMOTE_COMMIT_FILE`
# Download the version to update
cd $TMP_FOLDER
wget --timeout=10 https://github.com/lra/pouet.net/archive/$REMOTE_COMMIT.zip
# Unpack it
unzip $REMOTE_COMMIT.zip
# Copy any new file over the live folder
$RSYNC pouet.net-$REMOTE_COMMIT/ $LIVE_FOLDER
# Update the new crontab
/usr/bin/crontab $LIVE_FOLDER/crontab
# Everything is good, nothing failed, remove the wanted version and tag the
# new local version
rm $REMOTE_COMMIT_FILE
echo $REMOTE_COMMIT > $LOCAL_COMMIT_FILE
# Clean up the tmp folder to let the next deploy run
cd
rm -rf $TMP_FOLDER
fi