-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsync.sh
executable file
·59 lines (50 loc) · 1.29 KB
/
sync.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
#!/bin/sh
UPSTREAM=${1:-'@{u}'}
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse "$UPSTREAM")
BASE=$(git merge-base @ "$UPSTREAM")
send_mail () {
recipient=$( jq '.game.admin.email' config.json )
echo "sending failure email to ${recipient}"
sendmail $recipient < syncFailure.mail
}
if [ $LOCAL = $REMOTE ]; then
:
#echo "git: up-to-date"
else
echo "git: need to pull"
git reset --hard HEAD && git pull --rebase
if [ $? -eq 0 ]; then
echo "Success: pulled from git"
else
echo "Failure: Could not pull from git. Script failed" >&2
send_mail
exit 1
fi
make init-production
if [ $? -eq 0 ]; then
echo "Success: make init-production"
else
echo "Failure: make init-production. Script failed" >&2
send_mail
exit 1
fi
make clearCache
if [ $? -eq 0 ]; then
echo "Success: make clearCache"
else
echo "Failure: make clearCache. Script failed" >&2
send_mail
exit 1
fi
make migrateDatabase
if [ $? -eq 0 ]; then
echo "Success: make migrateDatabase"
else
echo "Failure: make migrateDatabase. Script failed" >&2
send_mail
exit 1
fi
jq '.game.version += 1' config/config.json | sponge config/config.json
exit 0
fi