forked from wthdevelopers/wthslack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·36 lines (27 loc) · 1.15 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
#!/bin/bash
# Provide CATEGORY_LIST & JUDGE_LIST arguments so as to self-modify code appropriately before launch
# Initialize cloud servers for Slack bot code
# Turn on database servers and cloud functions
# Created by James Raphael Tiovalen (2020)
sudo apt update
# Install dependencies for MySQL 8.0
sudo apt install -y mysql-server mysql-client
# Configure MySQL to start upon boot and start MySQL
sudo systemctl enable mysql.service
sudo systemctl start mysql.service
# Activate virtual environment and install dependencies
sudo apt install -y python3.8 python3.8-dev python3.8-venv
python3.8 -m venv "../env/"
source "../env/bin/activate"
python -m pip install --upgrade pip
python -m pip install -r "../requirements.txt"
# Expose mysql-server to open internet
sed "s/bind-address = 127.0.0.1/bind-address = 0.0.0.0/g" "/etc/mysql/mysql.conf.d/mysqld.cnf" > "/etc/mysql/mysql.conf.d/mysqld.cnf"
# Expose port 3306 to public
iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
# Run SQL script
mysql -u root -p < "db_scripts/setup.sql"
/etc/init.d/mysql restart
# Run Gunicorn
cd "../app"
gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker