Commit | Line | Data |
---|---|---|
63142550 LMM |
1 | #!/bin/bash |
2 | ||
3 | date_fmt="+%m-%d-%Y %H:%M:%S" | |
4 | ||
5 | local_checkout_base=/home/git/local/checkouts/edward | |
6 | package_path_base=/var/www/agpl.fsf.org/emailselfdefense.fsf.org/edward/ | |
7 | package_host=agpl.fsf.org | |
8 | package_name=edward | |
070744a1 | 9 | package_user=vcshookuser |
63142550 LMM |
10 | |
11 | repository=/home/git/repositories/edward.git | |
12 | remote_user=edward | |
13 | target_path=~$remote_user/edward-src | |
14 | ||
15 | doc_base=/var/www/docs/$package_name | |
16 | ||
17 | echo -n $(date "$date_fmt"); echo " - Starting post-update hook..." | |
18 | ||
19 | # Unset GIT_DIR to allow for calls to git clone/pull | |
20 | git update-server-info | |
21 | unset GIT_DIR | |
22 | ||
23 | ||
24 | # Extract the branch name | |
25 | branch=$(echo $1 | awk -F'/' '{print $3}') | |
26 | ||
27 | # Debug | |
28 | echo -n $(date "$date_fmt"); echo " - Processing branch: $1" | |
29 | ||
30 | # Set branch specific configurations | |
31 | case $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 | ;; | |
41 | esac | |
42 | ||
43 | doc_path=$doc_base/$branch | |
44 | ||
45 | echo -n $(date "$date_fmt"); echo " - Target host: $target_host" | |
46 | echo -n $(date "$date_fmt"); echo " - Target path: $target_path" | |
47 | echo -n $(date "$date_fmt"); echo " - Package host: $package_host" | |
48 | echo -n $(date "$date_fmt"); echo " - Package path: $package_path" | |
49 | echo -n $(date "$date_fmt"); echo " - Remote user: $remote_user" | |
50 | ||
51 | # See if local checkout exists | |
52 | if [ ! -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 |
58 | else |
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 |
63 | fi |
64 | ||
070744a1 | 65 | echo -n $(date "$date_fmt"); echo " - Packing zip and tarball for package host" |
63142550 LMM |
66 | rm -f $local_checkout_base/*tar.gz |
67 | rm -f $local_checkout_base/*zip | |
68 | cd $local_checkout_base | |
070744a1 LMM |
69 | tar czv --exclude-vcs -f $package_name.tar.gz $branch &>/dev/null |
70 | zip -r $package_name $branch -x "*/.git/*" "*/.gitignore" &>/dev/null | |
63142550 | 71 | |
070744a1 | 72 | echo -n $(date "$date_fmt"); echo " - Pushing to packaging server: https://$package_host/emailselfdefense.fsf.org/edward/" |
ead33f42 | 73 | scp $package_name.zip $package_name.tar.gz $package_user@$package_host:$package_path/ >/dev/null |
f0dbc87e LMM |
74 | ssh $package_user@$package_host ln -s $package_path/$package_name.tar.gz $package_path/edward/edward.tar.gz |
75 | ssh $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 | |
78 | if [ -z $target_host ]; then | |
79 | exit | |
80 | fi | |
81 | ||
82 | echo -n $(date "$date_fmt"); echo " - Pushing files to target host: $target_host:$target_path" | |
4f35e135 | 83 | rsync -arvPSX --exclude=lang/ --exclude=.git/ --delete $local_checkout/* $remote_user@$target_host:$target_path/ &>/dev/null |
63142550 | 84 |