#
echo "------- post-update started -------"
-ssh www-data@ryf.fsf.org "cd /var/www/git;git pull"
+# Disabling this, we're moving to rsync because it works better.
+#ssh www-data@ryf.fsf.org "cd /var/www/git;git pull"
+unset GIT_DIR
+SELF=ryf.git
+REPO_DIR=$HOME/repositories
+CHECKOUT_DIR=$HOME/local/checkouts/$SELF
+TARGET_DIR=/var/www/ryf.fsf.org
+TARGET_HOST=ryf.fsf.org
+
+
+case $1 in
+ refs/heads/live)
+ branch=live
+ ;;
+ refs/heads/dev)
+ branch=dev
+ ;;
+*)
+ echo "No action for this branch!"
+ ;;
+esac
+
+
+echo "Updating local checkout..."
+if [ ! -d $CHECKOUT_DIR ]; then
+ git clone $REPO_DIR/$SELF $CHECKOUT_DIR
+ cd $CHECKOUT_DIR
+ git checkout $branch
+else
+ cd $CHECKOUT_DIR
+ git checkout $branch
+ git pull origin $branch
+fi
+
+if [ -n $TARGET_HOST ]; then
+ echo Deploying to: $branch
+ rsync -avrSPX --delete-after $CHECKOUT_DIR/* root@$TARGET_HOST:$TARGET_DIR/
+fi
+
+exec git update-server-info
echo "------- post-update finished ------"