-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·51 lines (39 loc) · 1.17 KB
/
deploy.sh
File metadata and controls
executable file
·51 lines (39 loc) · 1.17 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
PIPCMD="pip"
PYTHONCMD="python3"
# set -x # prints commands as they are executed
# dependencies for printserver
$PIPCMD install -r requirements.txt
# make migrations
$PYTHONCMD printserver/manage.py makemigrations users prints
$PYTHONCMD printserver/manage.py migrate
# Collect static
$PYTHONCMD printserver/manage.py collectstatic
# Add user to database
$PYTHONCMD printserver/manage.py shell < printserver/add_user_script.py
# install nginx
sudo apt install nginx-full
# Write config file for nginx
current_dir=$(pwd)
echo "current_dir: $current_dir"
nginx_config="server {
listen 8001;
location /collectedstatic/ {
root $current_dir/printserver/;
}
add_header Access-Control-Allow-Origin *;
}"
nginx_config_file="/etc/nginx/conf.d/pstatic.conf"
touch $nginx_config_file
chmod +w $nginx_config_file
echo $nginx_config > $nginx_config_file
# Restart nginx
nginx -s reload
# test nginx
x=$(curl -X GET http://localhost:8001/collectedstatic/js/all.js)
if [ -z "$x" ]; then
echo "nginx not working"
exit 1
fi
echo "Chanage static_url in /printserver/printserver/settings.py to http://IP_FOR_STATICSERVER:8001/collectedstatic/"
# Run server
$PYTHONCMD printserver/manage.py runserver