forked from PnX-SI/GeoNature-atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_app.sh
executable file
·103 lines (84 loc) · 3.49 KB
/
install_app.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
95
96
97
98
99
100
101
102
103
#!/bin/bash
if [ "$(id -u)" == "0" ]; then
echo -e "\e[91m\e[1mThis script should NOT be run as root\e[0m" >&2
exit 1
fi
if [ ! -d 'log' ]
then
mkdir log
touch log/errors_atlas.log
fi
if [ ! -f ./atlas/configuration/settings.ini ]; then
cp ./atlas/configuration/settings.ini.sample ./atlas/configuration/settings.ini
fi
. atlas/configuration/settings.ini
if [ "$(id -u)" == "0" ]; then
echo -e "\e[91m\e[1mThis script should NOT be run as root but your user needs sudo rights\e[0m" >&2
exit 1
fi
echo "Stopping application..."
sudo -s supervisorctl stop atlas
echo "Creating and activating Virtual env..."
if [ -d $venv_dir/ ]
then
echo "Suppression du virtual env existant..."
sudo rm -rf $venv_dir
fi
virtualenv -p $python_executable $venv_dir
. $venv_dir/bin/activate
echo "Installing requirements..."
pip install -r requirements.txt
deactivate
echo "Creating configuration files if they dont already exist"
if [ ! -f ./atlas/configuration/config.py ]; then
cp ./atlas/configuration/config.py.sample ./atlas/configuration/config.py
fi
sudo sed -i "s/database_connection = .*$/database_connection = \"postgresql:\/\/$user_pg:$user_pg_pass@$db_host:$db_port\/$db_name\"/" ./atlas/configuration/config.py
sed -i "s/GUNICORN_PORT = .*$/GUNICORN_PORT = '${gun_port}'/g" ./atlas/configuration/config.py
echo "Launching application..."
DIR=$(readlink -e "${0%/*}")
sudo -s cp atlas-service.conf /etc/supervisor/conf.d/
sudo -s sed -i "s%APP_PATH%${DIR}%" /etc/supervisor/conf.d/atlas-service.conf
sudo -s supervisorctl reread
sudo -s supervisorctl reload
echo "Creating custom images folder if it doesnt already exist"
if [ ! -d ./static/custom/images/ ]; then
mkdir -p ./static/custom/images/
fi
echo "Creating customisation files if they dont already exist"
if [ ! -f ./static/custom/templates/footer.html ]; then
cp ./static/custom/templates/footer.html.sample ./static/custom/templates/footer.html
fi
if [ ! -f ./static/custom/templates/introduction.html ]; then
cp ./static/custom/templates/introduction.html.sample ./static/custom/templates/introduction.html
fi
if [ ! -f ./static/custom/templates/presentation.html ]; then
cp ./static/custom/templates/presentation.html.sample ./static/custom/templates/presentation.html
fi
if [ ! -f ./static/custom/templates/credits.html ]; then
cp ./static/custom/templates/credits.html.sample ./static/custom/templates/credits.html
fi
if [ ! -f ./static/custom/templates/mentions-legales.html ]; then
cp ./static/custom/templates/mentions-legales.html.sample ./static/custom/templates/mentions-legales.html
fi
if [ ! -f ./static/custom/custom.css ]; then
cp ./static/custom/custom.css.sample ./static/custom/custom.css
fi
if [ ! -f ./static/custom/glossaire.json ]; then
cp ./static/custom/glossaire.json.sample ./static/custom/glossaire.json
fi
if [ ! -f ./static/custom/images/favicon.ico ]; then
cp ./static/images/sample.favicon.ico ./static/custom/images/favicon.ico
fi
if [ ! -f ./static/custom/images/accueil-intro.jpg ]; then
cp ./static/images/sample.accueil-intro.jpg ./static/custom/images/accueil-intro.jpg
fi
if [ ! -f ./static/custom/images/logo-structure.png ]; then
cp ./static/images/sample.logo-structure.png ./static/custom/images/logo-structure.png
fi
if [ ! -f ./static/custom/images/logo_patrimonial.png ]; then
cp ./static/images/sample.logo_patrimonial.png ./static/custom/images/logo_patrimonial.png
fi
if [ ! -f ./static/custom/maps-custom.js ]; then
cp ./static/custom/maps-custom.js.sample ./static/custom/maps-custom.js
fi