-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·82 lines (72 loc) · 2.36 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
###############################################################################
#
# Copyright © Tobias Kühne
#
# You may use and distribute this software free of charge for non-commercial
# purposes. The software must be distributed in its entirety, i.e. containing
# ALL binary and source files without modification.
# Publication of modified versions of the source code provided herein,
# is permitted only with the author's written consent. In this case the
# copyright notice must not be removed or altered, all modifications to the
# source code must be clearly marked as such.
#
###############################################################################
set -euo pipefail
readonly SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}")
readonly root=httpdocs/vault/fra-flugplan
git -C "$SCRIPTDIR" diff-index --quiet HEAD -- ||
{
echo "Working copy is dirty. Aborting." >&2
exit 1
}
if ! tag=$(git -C "$SCRIPTDIR" describe --tags --exact-match); then
echo "Cannot determine tag." >&2
exit 1
fi
rev=$(git -C "$SCRIPTDIR" log -1 --no-show-signature --pretty="Version $tag@%h %cd")
# If checked out under Windows, cygwin permissions are wrong, which
# may lead to permissions being wrong on the server.
ssh fra-flugplan.de "mkdir -p $root httpdocs/var/log"
ssh fra-flugplan.de "rm -rf $root/$tag"
rsync -av \
--exclude="~*" \
--exclude="*~" \
--exclude="*.pdn" \
--filter="+ .config" \
--filter="+ .htaccess" \
--filter="+ apple-touch-icon.png" \
--filter="+ classes/" \
--filter="+ classes/*" \
--filter="+ content/" \
--filter="+ content/*" \
--filter="+ content/img/de" \
--filter="+ content/img/de/*" \
--filter="+ content/img/en" \
--filter="+ content/img/en/*" \
--filter="+ content/language/*" \
--filter="+ css/" \
--filter="+ css/*" \
--filter="+ css/ie/*" \
--filter="+ error.php" \
--filter="+ favicon.*" \
--filter="+ forms/" \
--filter="+ forms/*" \
--filter="+ getflights.*" \
--filter="+ git-rev" \
--filter="+ img/" \
--filter="- img/src" \
--filter="+ img/*" \
--filter="+ index.php" \
--filter="+ nav.php" \
--filter="+ photodb.php" \
--filter="+ redirect.php" \
--filter="+ robots.txt" \
--filter="+ script/" \
--filter="+ script/*" \
--filter="+ script/jquery*/***" \
--filter="+ user.php" \
--filter="- *" \
"$SCRIPTDIR/" fra-flugplan.de:"$root/$tag"
ssh fra-flugplan.de "echo $tag > $root/target; echo '$rev' > $root/$tag/git-rev"
echo -e "\033[32mSUCCESS.\033[m"