-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·71 lines (54 loc) · 1.61 KB
/
install.sh
File metadata and controls
executable file
·71 lines (54 loc) · 1.61 KB
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
#!/bin/bash
# need to do this to get dependencies
sudo apt-get install python3-venv
PROJECT_NAME=locutus
CURRENT_DIR=`pwd`
DEPLOY_DIR=/var/www/locutus
VENV_DIR=${PROJECT_NAME}.venv
# port to serve on
PORT=8040
mkdir ${VENV_DIR}
python3 -m venv ${VENV_DIR}
source ${VENV_DIR}/bin/activate
pip install --upgrade pip
pip install -r app/requirements.txt
# install uwsgi and create systemd service
pip install uwsgi
sudo ln -s ${CURRENT_DIR} ${DEPLOY_DIR}
echo """
[Unit]
Description=uWSGI instance to serve Bogdan's pet project
After=network.target
[Service]
User=bogdanv
Group=www-data
WorkingDirectory=${DEPLOY_DIR}
Environment="PATH=${DEPLOY_DIR}/${VENV_DIR}/bin"
ExecStart=${DEPLOY_DIR}/${VENV_DIR}/bin/uwsgi --ini uwsgi.ini
[Install]
WantedBy=multi-user.target
""" > ${PROJECT_NAME}.service
sudo mv ${PROJECT_NAME}.service /etc/systemd/system/
sudo systemctl start ${PROJECT_NAME}
# Nginx part
sudo apt-get install nginx
echo """
server {
listen ${PORT} default_server;
listen [::]:${PORT} default_server;
# TODO: set up letsencrypt certificates autogen
server_name _;
location /static/ {
root /var/www/locutus/app/;
}
location / { try_files \$uri/ @locutus; }
location @locutus {
include uwsgi_params;
uwsgi_pass unix:/var/www/locutus/locutus.sock;
}
}
""" > ${PROJECT_NAME}.nginx
sudo mv ${PROJECT_NAME}.nginx /etc/nginx/sites-available/${PROJECT_NAME}
sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/${PROJECT_NAME} /etc/nginx/sites-enabled/${PROJECT_NAME}
sudo service nginx restart