--- /dev/null
+#!/bin/bash
+
+unset GIT_DIR
+SELF=civicrm-core.git
+REPO_DIR=$HOME/repositories
+CHECKOUT_DIR=$HOME/local/checkouts/deploy-hooks
+TARGET_DIR=/var/www/html/
+
+case $1 in
+ refs/heads/master)
+ TARGET_HOST=crm.fsf.org
+ branch=master
+ ;;
+ refs/heads/stable)
+ TARGET_HOST=crm-dev.fsf.org
+ branch=stable
+ ;;
+ *)
+ echo "No action for this branch!"
+ ;;
+esac
+
+
+echo "Updating local checkout..."
+if [ ! -d $CHECKOUT_DIR ]; then
+ git clone $REPO_DIR/$SELF $CHECKOUT_DIR
+ git checkout $branch
+ cd $CHECKOUT_DIR
+else
+ cd $CHECKOUT_DIR
+ git checkout $branch
+ git pull origin $branch
+fi
+
+if [ -n TARGET_HOST ]; then
+ echo "Deploying branch '$branch' to host '$TARGET_HOST'"
+
+ echo "Uploading files to $TARGET_HOST web root..."
+ rsync -avrSPX --exclude='.git/' --delete $CHECKOUT_DIR/
+ vcshookuser@$TARGET_HOST:$TARGET_DIR
+
+ echo "Fixing permissions on webserver..."
+ ssh vcshookuser@$TARGET_HOST 'sudo /usr/loca/bin/fixperms.sh'
+fi
+
+exec git update-server-info
+
+