forked from louislam/uptime-kuma
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate-cloudcircus.sh
83 lines (68 loc) · 1.38 KB
/
update-cloudcircus.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
83
# Description: Update cloudcircus dist from github pull request
# Similar to `extra/download-dist.js`
# but this script is for cloudcircus
#
# Usage: sh update-cloudcircus.sh <download url>
if [ -z $1 ]; then
echo "Error: Need download url as argument"
exit 1
fi
echo "====================="
echo "Update git repository"
echo ""
git fetch --all
git checkout cloudcircus
git pull origin cloudcircus
echo ""
echo "====================="
echo "Install dependencies"
echo ""
npm install --production
DIST_DIR=dist
BACKUP_DIR=dist-backup
ZIP_FILE=dist.tar.gz
echo ""
echo "====================="
echo "Download release dist from github"
echo ""
# backup dist
if [ -d $DIST_DIR ]; then
if [ -d $BACKUP_DIR ]; then
# remove old backup
rm -rf $BACKUP_DIR
fi
# backup
mv $DIST_DIR $BACKUP_DIR
fi
# download dist zip from github
curl -OL $1
if [ $? -ne 0 ]; then
# if error
echo ""
echo "Error: Failed to download dist"
# rollback
mv $BACKUP_DIR $DIST_DIR
exit 1
fi
echo ""
echo "====================="
echo "Unzip release dist"
echo ""
tar -zxvf $ZIP_FILE
if [ $? -ne 0 ]; then
# if error
echo ""
echo "Error: Failed to unzip downloaded dist"
# rollback
mv $BACKUP_DIR $DIST_DIR
exit 1
else
# Done
echo ""
echo "Done"
# remove backup
rm -rf $BACKUP_DIR
fi
# remove zip file
rm -rf $ZIP_FILE
exit 0