-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·68 lines (50 loc) · 1.51 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
#! /bin/bash
cd `dirname $0`
echo $HOSTNAME
if [[ "$HOSTNAME" == isucon1 ]]; then
INSTANCE_NUM="1"
elif [[ "$HOSTNAME" == isucon2 ]]; then
INSTANCE_NUM="2"
elif [[ "$HOSTNAME" == isucon3 ]]; then
INSTANCE_NUM="3"
else
echo "Invalid host"
exit 1
fi
set -ex
git pull
sudo systemctl daemon-reload
# NGINX
if [[ "$INSTANCE_NUM" == 1 ]]; then
sudo install -o root -g root -m 644 ./conf/nginx/sites-available/isuports.conf /etc/nginx/sites-available/isuports.conf
sudo install -o root -g root -m 644 ./conf/nginx/nginx.conf /etc/nginx/nginx.conf
sudo nginx -t
sudo systemctl restart nginx
sudo systemctl enable nginx
fi
if [[ "$INSTANCE_NUM" == 2 || "$INSTANCE_NUM" == 3 ]]; then
sudo systemctl stop nginx.service
sudo systemctl disable nginx.service
fi
# APP
if [[ "$INSTANCE_NUM" == 1 ]]; then
sudo systemctl restart isuports.service
sudo systemctl enable isuports.service
sleep 2
sudo systemctl status isuports.service --no-pager
fi
if [[ "$INSTANCE_NUM" == 2 || "$INSTANCE_NUM" == 3 ]]; then
sudo systemctl stop isuports.service
sudo systemctl disable isuports.service
fi
# MYSQL
if [[ "$INSTANCE_NUM" == 1 ]]; then
sudo systemctl stop mysql.service
sudo systemctl disable mysql.service
fi
if [[ "$INSTANCE_NUM" == 2 || "$INSTANCE_NUM" == 3 ]]; then
sudo install -o root -g root -m 644 ./conf/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf
echo "MySQL restart したいなら手動でやってね"
# sudo systemctl restart mysql
sudo systemctl enable mysql
fi