-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdeploy.sh
executable file
·83 lines (70 loc) · 1.89 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
83
if [ "$1" == "prod" ] ; then
if [ "$2" != "confirm" ] && [ "$3" != "confirm" ] && [ "$4" != "confirm" ]; then
echo "Must add 'confirm' to deploy to prod"
exit 1
fi
HOST="[email protected]"
elif [ "$1" == "dev" ] ; then
HOST="[email protected]"
else
echo "Must specify environment (dev|prod)"
exit 1
fi
FOLDER="acpic"
wc -l client.js server.js testclient.js testserver.js admin.js config.js secret.js deploy.sh
if [ "$2" == "client" ] ; then
scp client.js $HOST:$FOLDER
exit 0
fi
if [ "$2" == "channel" ] ; then
scp channel.js $HOST:$FOLDER/channel.js
exit 0
fi
\
if [ "$2" == "testclient" ] ; then
scp testclient.js $HOST:$FOLDER
exit 0
fi
if [ "$2" == "admin" ] ; then
scp admin.js $HOST:$FOLDER
exit 0
fi
if [ "$2" == "home" ] ; then
scp -r home/* $HOST:$FOLDER/home
exit 0
fi
if [ "$2" == "gotoB" ] ; then
scp assets/gotoB.min.js $HOST:$FOLDER/assets
exit 0
fi
if [ "$2" == "server" ] ; then
scp server.js $HOST:$FOLDER
ssh $HOST "cd $FOLDER && mg restart"
exit 0
fi
if [ "$2" == "makeConsistent" ] ; then
ssh $HOST "cd $FOLDER && mg stop"
ssh $HOST "cd $FOLDER && node server $1 makeConsistent"
ssh $HOST "cd $FOLDER && mg restart"
exit 0
fi
if [ "$2" == "checkConsistency" ] ; then
ssh $HOST "cd $FOLDER && node server $1 checkConsistency"
exit 0
fi
if [ "$2" == "script" ] ; then
scp $3 $HOST:$FOLDER/$3
ssh $HOST "cd $FOLDER && node server $1 script $3"
exit 0
fi
if [ "$2" == "test" ] ; then
rsync -av . $HOST:$FOLDER
ssh $HOST chown -R root /root/$FOLDER
echo "main = node server $1" | ssh $HOST "cat >> $FOLDER/mongroup.conf"
ssh $HOST "cd $FOLDER && node testserver $3 $4 $5"
exit 0
fi
rsync -av . $HOST:$FOLDER
ssh $HOST chown -R root /root/$FOLDER
echo "main = node server $1" | ssh $HOST "cat >> $FOLDER/mongroup.conf"
ssh $HOST "cd $FOLDER && npm i --no-save --omit=dev && mg restart"