From 3737ba4877781f441c8b8ab8466c8a57f7ab402a Mon Sep 17 00:00:00 2001 From: Lisa Marie Maginnis Date: Thu, 9 Jul 2015 11:08:21 -0400 Subject: [PATCH] changed variables for tcpinreceiver --- tc-ipn-receiver.git/post-update | 91 +++++++++++++++++++++++++-------- 1 file changed, 71 insertions(+), 20 deletions(-) diff --git a/tc-ipn-receiver.git/post-update b/tc-ipn-receiver.git/post-update index d73acc5..15a4e30 100755 --- a/tc-ipn-receiver.git/post-update +++ b/tc-ipn-receiver.git/post-update @@ -1,34 +1,85 @@ -#!/bin/bash +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". +date_fmt="+%m-%d-%Y %H:%M:%S" + +local_checkout_base=/home/git/local/checkouts/trustcommerce +package_path_base=/var/www/agpl.fsf.org/crm.fsf.org +package_host=agpl.fsf.org +package_name=tc-ipn-receiver + +repository=/home/git/repositories/trustcommerce.git +remote_user=vcshookuser +target_path=~$remote_user/stage/tc-ipn-receiver + +deploy_script=/usr/local/bin/deploy-tc-ipn-receiver.sh + +echo -n $(date "$date_fmt"); echo " - Starting post-update hook..." + +# Unset GIT_DIR to allow for calls to git clone/pull +git update-server-info unset GIT_DIR -SELF=deploy_hooks.git -REPO_DIR=$HOME/repositories -CHECKOUT_DIR=$HOME/local/checkouts/deploy-hooks -case $1 in - refs/heads/stable) - echo "Updating hooks on vcs.fsf.org..." + +# Extract the branch name +branch=$(echo $1 | awk -F'/' '{print $3}') + +# Debug +echo -n $(date "$date_fmt"); echo " - Processing branch: $1" + +# Set branch specific configurations +case $branch in + master) + package_path=$package_path_base/devel + local_checkout=$local_checkout_base/$branch + target_host=crm-dev.fsf.org + ;; + live) + package_path=$package_path_base/$branch + local_checkout=$local_checkout_base/$branch + target_host=crm.fsf.org ;; *) - echo 'No rules for this branch!' - exit 0 + echo $branch was deleted + exit ;; esac -echo "Updating local checkout..." -if [ ! -d $CHECKOUT_DIR ]; then - git clone $REPO_DIR/$self $CHECKOUT_DIR - git checkout stable +echo -n $(date "$date_fmt"); echo " - Target host: $target_host" +echo -n $(date "$date_fmt"); echo " - Target path: $target_path" +echo -n $(date "$date_fmt"); echo " - Package host: $package_host" +echo -n $(date "$date_fmt"); echo " - Package path: $package_path" +echo -n $(date "$date_fmt"); echo " - Remote user: $remote_user" + +# See if local checkout exists +if [ ! -d $local_checkout ]; then + echo -n $(date "$date_fmt"); echo " - No local checkout detected, creating now" + git clone $repository $local_checkout + cd $local_checkout else - cd $CHECKOUT_DIR - git pull origin stable + echo -n $(date "$date_fmt"); echo " - Updating local checkout" + cd $local_checkout + git pull origin $branch fi -echo "Syncing hooks..." -for working_copy in $(find $CHECKOUT_DIR -type d -maxdepth 1 -name '*git'); do - rsync -avrSPX --delete $working_copy/hooks/* $REPO_DIR/{$working_copy//*\//}/hooks/ -done +echo -n $(date "$date_fmt"); echo " - Pushing files to target host" +rsync -arzSPX --exclude=.git/ --delete $local_checkout/* $remote_user@$target_host:$target_path/ #2>/dev/null + +echo -n $(date "$date_fmt"); echo " - Updating target path permissions" +ssh $remote_user@$target_host -t sudo $deploy_script + +echo -n $(date "$date_fmt"); echo " - Packing for export to package host" +rm -f $local_checkout_base/*tar.gz +rm -f $local_checkout_base/*zip +cd $local_checkout_base +tar czv --exclude-vcs -f $package_name.tar.gz $branch +zip -r $package_name $branch -x "*/.git/*" "*/.gitignore" -exec git update-server-info +echo -n $(date "$date_fmt"); echo " - Pushing to packaging server" +scp $package_name.zip $package_name.tar.gz $remote_user@$package_host:$package_path/ -- 2.25.1