-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·44 lines (30 loc) · 1.22 KB
/
update.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
#!/bin/zsh
bold=$(tput bold)
normal=$(tput sgr0)
# DEBUG
# set -euxo pipefail
cd /home/ubuntu/recettes
echo "\n${bold}→ GIT - Pulling source code${normal}"
git pull;
echo "\n${bold}→ PYTHON ENV - Activating virtualenv${normal}"
source ./env/bin/activate
echo "\n${bold}→ PYTHON ENV - Installing packages${normal}"
pip install -r requirements.txt
echo "\n${bold}→ DJANGO - Migrating Databases${normal}"
python manage.py makemigrations
python manage.py migrate
echo "\n${bold}→ DJANGO - Collecting static files${normal}"
python manage.py collectstatic --no-input
echo "\n${bold}→ SERVER - Copying server configuration${normal}"
sudo cp -v ops/gunicorn.conf /etc/systemd/system/gunicorn.service
sudo cp -v ops/nginx.conf /etc/nginx/sites-available/recettes
sudo ln -v -f -s /etc/nginx/sites-available/recettes /etc/nginx/sites-enabled/recettes
echo "\n${bold}→ SERVER - Reload Daemons${normal}"
sudo systemctl daemon-reload
echo "\n${bold}→ SERVER - Restarting gunicorn${normal}"
sudo systemctl restart gunicorn
echo "\n${bold}→ SERVER - Restarting nginx${normal}"
sudo systemctl restart nginx
echo "\n${bold}→ PYTHON ENV - Exiting virtualenv${normal}"
deactivate
echo "\n${bold}→ Updating successful!${normal}"