-
Notifications
You must be signed in to change notification settings - Fork 95
/
post-deploy.sh
executable file
·94 lines (72 loc) · 2.03 KB
/
post-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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash
echo ""
echo ""
echo " --- Checking whether '.venv' VirtualEnv is activated."
python -c 'import sys; exit_code = 0 if hasattr(sys, "real_prefix") else 1; sys.exit(exit_code);'
if [ $? -ne 0 ]; then
echo " [i] ----- Activating '.venv' VirtualEnv..."
source ~/dsmr-reader/.venv/bin/activate
if [ $? -ne 0 ]; then
echo ""
echo " [!] Aborting, failure switching to '.venv' VirtualEnv (is it installed properly?)"
echo ""
exit 1;
fi
fi
echo ""
echo ""
echo " --- Checking (minimum) Python version."
./check_python_version.py
if [ $? -ne 0 ]; then
echo ""
echo "[!] Aborting, failure CHECKING PYTHON VERSION"
echo ""
exit 1;
fi
echo ""
echo ""
echo " --- Checking & synchronizing base requirements for changes."
pip3 install -r dsmrreader/provisioning/requirements/base.txt --upgrade
if [ $? -ne 0 ]; then
echo ""
echo "[!] Aborting, failure RUNNING PIP INSTALL"
echo ""
exit 1;
fi
echo ""
echo ""
echo " --- Applying database migrations."
./manage.py migrate --noinput
if [ $? -ne 0 ]; then
echo ""
echo " >>>>> [!] Executing database migrations failed! <<<<<"
echo " [i] Trying to automatically resolve with 'dsmr_sqlsequencereset'."
# Try auto fix.
./manage.py dsmr_sqlsequencereset
# Run migrations again.
./manage.py migrate --noinput
if [ $? -ne 0 ]; then
echo ">>>>> [!] Executing database migrations failed again! <<<<<"
echo " - Running dsmr_sqlsequencereset did not resolve the problem."
echo " - Create an issue on GitHub and attach the exception trace listed above."
exit 1;
fi
fi
echo ""
echo ""
echo " --- Checking & synchronizing static file changes."
./manage.py collectstatic --noinput
if [ $? -ne 0 ]; then
echo ""
echo "[!] Aborting, failure COPYING STATIC FILES"
echo ""
exit 1;
fi
echo ""
echo ""
echo " --- Reloading running apps..."
./reload.sh
echo ""
echo ""
echo " --- Clearing cache..."
./manage.py dsmr_frontend_clear_cache