added symlink creation to edward.git
[deploy-hooks.git] / edward.git / post-update
CommitLineData
63142550
LMM
1#!/bin/bash
2
3date_fmt="+%m-%d-%Y %H:%M:%S"
4
5local_checkout_base=/home/git/local/checkouts/edward
6package_path_base=/var/www/agpl.fsf.org/emailselfdefense.fsf.org/edward/
7package_host=agpl.fsf.org
8package_name=edward
070744a1 9package_user=vcshookuser
63142550
LMM
10
11repository=/home/git/repositories/edward.git
12remote_user=edward
13target_path=~$remote_user/edward-src
14
15doc_base=/var/www/docs/$package_name
16
17echo -n $(date "$date_fmt"); echo " - Starting post-update hook..."
18
19# Unset GIT_DIR to allow for calls to git clone/pull
20git update-server-info
21unset GIT_DIR
22
23
24# Extract the branch name
25branch=$(echo $1 | awk -F'/' '{print $3}')
26
27# Debug
28echo -n $(date "$date_fmt"); echo " - Processing branch: $1"
29
30# Set branch specific configurations
31case $branch in
32 master)
33 local_checkout=$local_checkout_base/$branch
34 package_path=$package_path_base/
35 target_host=fencepost.gnu.org
36 ;;
37 *)
4f35e135 38 echo Hook for $branch does not exist, taking no further action.
63142550
LMM
39 exit
40 ;;
41esac
42
43doc_path=$doc_base/$branch
44
45echo -n $(date "$date_fmt"); echo " - Target host: $target_host"
46echo -n $(date "$date_fmt"); echo " - Target path: $target_path"
47echo -n $(date "$date_fmt"); echo " - Package host: $package_host"
48echo -n $(date "$date_fmt"); echo " - Package path: $package_path"
49echo -n $(date "$date_fmt"); echo " - Remote user: $remote_user"
50
51# See if local checkout exists
52if [ ! -d $local_checkout ]; then
53 echo -n $(date "$date_fmt"); echo " - No local checkout detected, creating now"
54 mkdir -p $local_checkout
ead33f42 55 git clone $repository $local_checkout &>/dev/null
63142550 56 cd $local_checkout
ead33f42 57 git checkout $branch &>/dev/null
63142550
LMM
58else
59 echo -n $(date "$date_fmt"); echo " - Updating local checkout"
60 cd $local_checkout
ead33f42
LMM
61 git checkout $branch &>/dev/null
62 git pull origin $branch &>/dev/null
63142550
LMM
63fi
64
070744a1 65echo -n $(date "$date_fmt"); echo " - Packing zip and tarball for package host"
63142550
LMM
66rm -f $local_checkout_base/*tar.gz
67rm -f $local_checkout_base/*zip
68cd $local_checkout_base
070744a1
LMM
69tar czv --exclude-vcs -f $package_name.tar.gz $branch &>/dev/null
70zip -r $package_name $branch -x "*/.git/*" "*/.gitignore" &>/dev/null
63142550 71
070744a1 72echo -n $(date "$date_fmt"); echo " - Pushing to packaging server: https://$package_host/emailselfdefense.fsf.org/edward/"
ead33f42 73scp $package_name.zip $package_name.tar.gz $package_user@$package_host:$package_path/ >/dev/null
f0dbc87e
LMM
74ssh $package_user@$package_host ln -s $package_path/$package_name.tar.gz $package_path/edward/edward.tar.gz
75ssh $package_user@$package_host ln -s $package_path/$package_name.zip $package_path/edward/edward.zip
63142550
LMM
76
77# Stop here if not updating a host
78if [ -z $target_host ]; then
79 exit
80fi
81
82echo -n $(date "$date_fmt"); echo " - Pushing files to target host: $target_host:$target_path"
4f35e135 83rsync -arvPSX --exclude=lang/ --exclude=.git/ --delete $local_checkout/* $remote_user@$target_host:$target_path/ &>/dev/null
63142550 84