-
Notifications
You must be signed in to change notification settings - Fork 2
/
deploy.sh
executable file
·75 lines (56 loc) · 1.86 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
#!/bin/bash
PRODUCTION=146.148.12.163
PREPRODUCTION=104.199.46.184
#############################
## deploy to preproduction ##
#############################
ssh-keyscan -t rsa -H $PREPRODUCTION >> ~/.ssh/known_hosts
ssh -oStrictHostKeyChecking=no -i secret travis@$PREPRODUCTION << EOF
echo "***** hostname"
hostname
echo "***** sudo rm -r chat/"
sudo rm -r chat/
echo -e "\n***** git clone https://github.com/Kami11/chat.git"
git clone https://github.com/Kami11/chat.git
cd chat/
pwd
echo -e "\n***** sudo -H ./setup.py install"
sudo -H python3 setup.py install
echo -e "\n***** sudo killall python3"
sudo killall python3
EOF
echo "**** ssh -i secret -t travis@$PREPRODUCTION 'sudo ./chat/bin/kisschat -a 0.0.0.0 -p 80' &"
ssh -i secret -t travis@$PREPRODUCTION ' cd chat/ && sudo kisschat -a 0.0.0.0 -p 80 ' &
sleep 3
echo "done deploy to preproduction"
#############################
## The acceptance tests ##
#############################
if ./acceptance_test.sh $PREPRODUCTION
then
#############################
## deploy to production ##
#############################
ssh-keyscan -t rsa -H $PRODUCTION >> ~/.ssh/known_hosts
ssh -oStrictHostKeyChecking=no -i secret travis@$PRODUCTION << EOF
echo "***** hostname"
hostname
echo "***** sudo rm -r chat/"
sudo rm -r chat/
echo -e "\n***** git clone https://github.com/Kami11/chat.git"
git clone https://github.com/Kami11/chat.git
cd chat/
pwd
echo "\n***** sudo -H ./setup.py install"
sudo -H python3 setup.py install
echo "\n***** sudo killall python3"
sudo killall python3
EOF
echo "**** ssh -i secret -t travis@$PRODUCTION 'sudo ./chat/bin/kisschat -a 0.0.0.0 -p 80' &"
ssh -i secret -t travis@$PRODUCTION ' cd chat/ && sudo kisschat -a 0.0.0.0 -p 80 ' &
sleep 3
echo "done deploy to production"
else
echo 'The acceptance tests is failed, WebSocket did not work, can not to deploy to production'
exit 1
fi