3 # An example hook script to prepare a packed repository for use over
6 # To enable this hook, rename this file to "post-update".
8 date_fmt
="+%m-%d-%Y %H:%M:%S"
10 local_checkout_base
=/home
/git
/local
/checkouts
/trustcommerce
11 package_path_base
=/var
/www
/agpl.fsf.org
/crm.fsf.org
12 package_host
=agpl.fsf.org
13 package_name
=trustcommerce
15 repository
=/home
/git
/repositories
/trustcommerce.git
16 remote_user
=vcshookuser
17 target_path
=~
$remote_user/stage
/org.fsf.payment.trustcommerce
/
19 deploy_script
=/usr
/local
/bin
/deploy_tc.sh
21 echo -n $
(date "$date_fmt"); echo " - Starting post-update hook..."
23 # Unset GIT_DIR to allow for calls to git clone/pull
24 git update-server-info
28 # Extract the branch name
29 branch
=$
(echo $1 |
awk -F'/' '{print $3}')
32 echo -n $
(date "$date_fmt"); echo " - Processing branch: $1"
34 # Set branch specific configurations
37 package_path
=$package_path_base/devel
38 local_checkout
=$local_checkout_base/$branch
39 target_host
=crm-dev.fsf.org
42 package_path
=$package_path_base/$branch
43 local_checkout
=$local_checkout_base/$branch
44 target_host
=crm.fsf.org
47 echo $branch was deleted
52 echo -n $
(date "$date_fmt"); echo " - Target host: $target_host"
53 echo -n $
(date "$date_fmt"); echo " - Target path: $target_path"
54 echo -n $
(date "$date_fmt"); echo " - Package host: $package_host"
55 echo -n $
(date "$date_fmt"); echo " - Package path: $package_path"
56 echo -n $
(date "$date_fmt"); echo " - Remote user: $remote_user"
58 # See if local checkout exists
59 if [ ! -d $local_checkout ]; then
60 echo -n $
(date "$date_fmt"); echo " - No local checkout detected, creating now"
61 git clone
$repository $local_checkout
64 echo -n $
(date "$date_fmt"); echo " - Updating local checkout"
66 git pull origin
$branch
69 echo -n $
(date "$date_fmt"); echo " - Pushing files to target host"
70 rsync
-arzSPX --exclude=.git
/ --delete $local_checkout/* $remote_user@
$target_host:$target_path/ #2>/dev/null
72 echo -n $
(date "$date_fmt"); echo " - Updating target path permissions"
73 ssh $remote_user@
$target_host sudo
$deploy_script
75 echo -n $
(date "$date_fmt"); echo " - Packing for export to package host"
76 rm -f $local_checkout_base/*tar.gz
77 rm -f $local_checkout_base/*zip
78 cd $local_checkout_base
79 tar czv
--exclude-vcs -f $package_name.
tar.gz
$branch
80 zip -r $package_name $branch -x "*/.git/*" "*/.gitignore"
82 echo -n $
(date "$date_fmt"); echo " - Pushing to packaging server"
83 scp
$package_name.
zip $package_name.
tar.gz
$remote_user@
$package_host:$package_path/