changed variables for tcpinreceiver
[deploy-hooks.git] / tc-ipn-receiver.git / post-update
CommitLineData
3737ba48
LMM
1#!/bin/sh
2#
3# An example hook script to prepare a packed repository for use over
4# dumb transports.
5#
6# To enable this hook, rename this file to "post-update".
e1718353 7
3737ba48
LMM
8date_fmt="+%m-%d-%Y %H:%M:%S"
9
191fb92a 10local_checkout_base=/home/git/local/checkouts/tc-ipn-receiver
3737ba48
LMM
11package_path_base=/var/www/agpl.fsf.org/crm.fsf.org
12package_host=agpl.fsf.org
13package_name=tc-ipn-receiver
14
191fb92a 15repository=/home/git/repositories/tc-ipn-receiver.git
3737ba48
LMM
16remote_user=vcshookuser
17target_path=~$remote_user/stage/tc-ipn-receiver
18
19deploy_script=/usr/local/bin/deploy-tc-ipn-receiver.sh
20
21echo -n $(date "$date_fmt"); echo " - Starting post-update hook..."
22
23# Unset GIT_DIR to allow for calls to git clone/pull
24git update-server-info
e1718353 25unset GIT_DIR
e1718353 26
3737ba48
LMM
27
28# Extract the branch name
29branch=$(echo $1 | awk -F'/' '{print $3}')
30
31# Debug
32echo -n $(date "$date_fmt"); echo " - Processing branch: $1"
33
34# Set branch specific configurations
35case $branch in
36 master)
37 package_path=$package_path_base/devel
38 local_checkout=$local_checkout_base/$branch
39 target_host=crm-dev.fsf.org
40 ;;
41 live)
42 package_path=$package_path_base/$branch
43 local_checkout=$local_checkout_base/$branch
44 target_host=crm.fsf.org
e1718353
LMM
45 ;;
46 *)
3737ba48
LMM
47 echo $branch was deleted
48 exit
e1718353
LMM
49 ;;
50esac
51
3737ba48
LMM
52echo -n $(date "$date_fmt"); echo " - Target host: $target_host"
53echo -n $(date "$date_fmt"); echo " - Target path: $target_path"
54echo -n $(date "$date_fmt"); echo " - Package host: $package_host"
55echo -n $(date "$date_fmt"); echo " - Package path: $package_path"
56echo -n $(date "$date_fmt"); echo " - Remote user: $remote_user"
57
58# See if local checkout exists
59if [ ! -d $local_checkout ]; then
60 echo -n $(date "$date_fmt"); echo " - No local checkout detected, creating now"
61 git clone $repository $local_checkout
62 cd $local_checkout
e1718353 63else
3737ba48
LMM
64 echo -n $(date "$date_fmt"); echo " - Updating local checkout"
65 cd $local_checkout
66 git pull origin $branch
e1718353
LMM
67fi
68
3737ba48
LMM
69echo -n $(date "$date_fmt"); echo " - Pushing files to target host"
70rsync -arzSPX --exclude=.git/ --delete $local_checkout/* $remote_user@$target_host:$target_path/ #2>/dev/null
71
72echo -n $(date "$date_fmt"); echo " - Updating target path permissions"
73ssh $remote_user@$target_host -t sudo $deploy_script
74
75echo -n $(date "$date_fmt"); echo " - Packing for export to package host"
76rm -f $local_checkout_base/*tar.gz
77rm -f $local_checkout_base/*zip
78cd $local_checkout_base
79tar czv --exclude-vcs -f $package_name.tar.gz $branch
80zip -r $package_name $branch -x "*/.git/*" "*/.gitignore"
e1718353 81
3737ba48
LMM
82echo -n $(date "$date_fmt"); echo " - Pushing to packaging server"
83scp $package_name.zip $package_name.tar.gz $remote_user@$package_host:$package_path/
e1718353
LMM
84
85