-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_all_app.sh
263 lines (232 loc) · 13.7 KB
/
install_all_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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#!/bin/bash
# Installation complète de la suite d'outils Geonature du PNEcrins, pour un serveur Ubuntu 16.04 LTS
# Configuration initiale de l'installation serveur
. install_all.ini
# Make sure this script is NOT run as root
if [ "$(id -u)" == "0" ]; then
echo -e "\e[91m\e[1mThis script should NOT be run as root\e[0m" >&2
echo -e "\e[91m\e[1mLancez ce script avec l'utilisateur courant : '$monuser'\e[0m" >&2
exit 1
fi
###########
# USERSHUB
###########
# Installation de UsersHub avec l'utilisateur courant
echo "téléchargement et installation de UsersHub ..."
cd /tmp
wget https://github.com/PnEcrins/UsersHub/archive/$usershub_release.zip
unzip $usershub_release.zip
rm $usershub_release.zip
mv UsersHub-$usershub_release /home/$monuser/usershub/
cd /home/$monuser/usershub
# Configuration des settings de UsersHub
echo "Installation de la base de données et configuration de l'application UsersHub ..."
cp config/settings.ini.sample config/settings.ini
sed -i "s/drop_apps_db=.*$/drop_apps_db=$drop_usershubdb/g" config/settings.ini
sed -i "s/db_host=.*$/db_host=$pg_host/g" config/settings.ini
sed -i "s/db_name=.*$/db_name=$usershubdb_name/g" config/settings.ini
sed -i "s/user_pg=.*$/user_pg=$user_pg/g" config/settings.ini
sed -i "s/user_pg_pass=.*$/user_pg_pass=$user_pg_pass/g" config/settings.ini
# Installation de la base de données UsersHub en root
sudo ./install_db.sh
# Installation et configuration de l'application UsersHub
./install_app.sh
# Configuration de la connexion à la base de données GeoNature
rm config/dbconnexions.json
touch config/dbconnexions.json
echo "{" >> config/dbconnexions.json
echo " \"databases\":" >> config/dbconnexions.json
echo " [" >> config/dbconnexions.json
echo " {" >> config/dbconnexions.json
echo " \"dbfunname\":\"Utilisateurs\"" >> config/dbconnexions.json
echo " ,\"host\":\"$pg_host\"" >> config/dbconnexions.json
echo " ,\"dbname\":\"$usershubdb_name\"" >> config/dbconnexions.json
echo " ,\"user\":\"$user_pg\"" >> config/dbconnexions.json
echo " ,\"pass\":\"$user_pg_pass\"" >> config/dbconnexions.json
echo " ,\"port\":\"$pg_port\"" >> config/dbconnexions.json
echo " }" >> config/dbconnexions.json
echo " ,{" >> config/dbconnexions.json
echo " \"dbfunname\":\"GeoNature\"" >> config/dbconnexions.json
echo " ,\"host\":\"$pg_host\"" >> config/dbconnexions.json
echo " ,\"dbname\":\"$geonaturedb_name\"" >> config/dbconnexions.json
echo " ,\"user\":\"$user_pg\"" >> config/dbconnexions.json
echo " ,\"pass\":\"$user_pg_pass\"" >> config/dbconnexions.json
echo " ,\"port\":\"$pg_port\"" >> config/dbconnexions.json
echo " }" >> config/dbconnexions.json
echo " ]" >> config/dbconnexions.json
echo "}" >> config/dbconnexions.json
###########
# GEONATURE
###########
# Installation de GeoNature avec l'utilisateur courant
echo "Téléchargement et installation de GeoNature ..."
cd /tmp
wget https://github.com/PnEcrins/GeoNature/archive/$geonature_release.zip
unzip $geonature_release.zip
rm $geonature_release.zip
mv GeoNature-$geonature_release /home/$monuser/geonature/
cd /home/$monuser/geonature
# Configuration des settings de GeoNature
echo "Installation de la base de données et configuration de l'application GeoNature ..."
cp config/settings.ini.sample config/settings.ini
sed -i "s/drop_apps_db=.*$/drop_apps_db=$drop_geonaturedb/g" config/settings.ini
sed -i "s/db_name=.*$/db_name=$geonaturedb_name/g" config/settings.ini
sed -i "s/user_pg=.*$/user_pg=$user_pg/g" config/settings.ini
sed -i "s/db_host=.*$/db_host=$pg_host/g" config/settings.ini
sed -i "s/user_pg_pass=.*$/user_pg_pass=$user_pg_pass/g" config/settings.ini
sed -i "s/srid_local=.*$/srid_local=$srid_local/g" config/settings.ini
sed -i "s/add_sample_data=.*$/add_sample_data=$add_sample_data/g" config/settings.ini
sed -i "s/usershub_release=.*$/usershub_release=$usershub_release/g" config/settings.ini
sed -i "s/taxhub_release=.*$/taxhub_release=$taxhub_release/g" config/settings.ini
sed -i -e "s/\/var\/www/$apache_document_root/g" install_app.sh
# Installation de la base de données GeoNature en root
rm install_db.sh
wget https://raw.githubusercontent.com/Splendens/install_all_geonature_ubuntu16_04/master/install_geonature/install_db.sh
sudo chmod +x install_db.sh
sudo ./install_db.sh
./install_app.sh
# Configuration Apache de l'application GeoNature
cd /home/$monuser/geonature
sed -i -e "s/\/home\/synthese\/geonature/\/home\/$monuser\/geonature/g" apache/sf.conf
sed -i -e "s/\/home\/synthese\/geonature/\/home\/$monuser\/geonature/g" apache/wms.conf
sed -i -e "s/\/var\/www\/geonature/\/var\/www\/html\/geonature/g" apache/synthese.conf
sed -i -e "s/mon-domaine.fr/$mondomaine/g" web/js/config.js
sed -i -e "s/ma_cle_api_ign/$macleign/g" web/js/configmap.js
sudo sh -c 'echo "IncludeOptional /home/'$monuser'/geonature/apache/*.conf" >> /etc/apache2/apache2.conf'
#sudo apache2ctl restart
########
# TAXHUB
########
# Installation de TaxHub avec l'utilisateur courant
echo "Téléchargement et installation de TaxHub ..."
cd /tmp
wget https://github.com/PnX-SI/TaxHub/archive/$taxhub_release.zip
unzip $taxhub_release.zip
rm $taxhub_release.zip
mv TaxHub-$taxhub_release /home/$monuser/taxhub/
cd /home/$monuser/taxhub
# Configuration des settings de TaxHub
echo "Configuration de l'application TaxHub ..."
cp settings.ini.sample settings.ini
sed -i "s/drop_apps_db=.*$/drop_apps_db=false/g" settings.ini
sed -i "s/db_host=.*$/db_host=$pg_host/g" settings.ini
sed -i "s/db_port=.*$/db_port=$pg_port/g" settings.ini
sed -i "s/db_name=.*$/db_name=$geonaturedb_name/g" settings.ini
sed -i "s/user_pg=.*$/user_pg=$user_pg/g" settings.ini
sed -i "s/user_pg_pass=.*$/user_pg_pass=$user_pg_pass/g" settings.ini
sed -i "s/user_schema=.*$/user_schema=local/g" settings.ini
sed -i "s/usershub_host=.*$/usershub_host=$pg_host/g" settings.ini
sed -i "s/usershub_port=.*$/usershub_port=$pg_port/g" settings.ini
sed -i "s/usershub_db=.*$/usershub_db=$usershubdb_name/g" settings.ini
sed -i "s/usershub_user=.*$/usershub_user=$user_pg/g" settings.ini
sed -i "s/usershub_pass=.*$/usershub_pass=$user_pg_pass/g" settings.ini
# Configuration Apache de TaxHub
sudo touch /etc/apache2/sites-available/taxhub.conf
sudo sh -c 'echo "# Configuration TaxHub" >> /etc/apache2/sites-available/taxhub.conf'
#sudo sh -c 'echo "RewriteEngine on" >> /etc/apache2/sites-available/taxhub.conf'
#sudo sh -c 'echo "RewriteRule \"taxhub$\" \"taxhub/\" [R]" >> /etc/apache2/sites-available/taxhub.conf'
sudo sh -c 'echo "<Location /taxhub>" >> /etc/apache2/sites-available/taxhub.conf'
sudo sh -c 'echo "ProxyPass http://127.0.0.1:5000/ retry=0" >> /etc/apache2/sites-available/taxhub.conf'
sudo sh -c 'echo "ProxyPassReverse http://127.0.0.1:5000/" >> /etc/apache2/sites-available/taxhub.conf'
sudo sh -c 'echo "</Location>" >> /etc/apache2/sites-available/taxhub.conf'
sudo sh -c 'echo "#FIN Configuration TaxHub" >> /etc/apache2/sites-available/taxhub.conf'
sudo sed -i "s/<\/VirtualHost>//g" /etc/apache2/sites-available/000-default.conf
sudo sed -i "s/# vim.*$//g" /etc/apache2/sites-available/000-default.conf
sudo sh -c 'echo "# Configuration TaxHub - ne fonctionne pas dans le 000-default.conf" >> /etc/apache2/sites-available/000-default.conf'
sudo sh -c 'echo "RewriteEngine on" >> /etc/apache2/sites-available/000-default.conf'
sudo sh -c 'echo "RewriteRule \"taxhub$\" \"taxhub/\" [R]" >> /etc/apache2/sites-available/000-default.conf'
sudo sh -c 'echo "</VirtualHost>" >> /etc/apache2/sites-available/000-default.conf'
sudo sh -c 'echo "" >> /etc/apache2/sites-available/000-default.conf'
sudo sh -c 'echo "# vim: syntax=apache ts=4 sw=4 sts=4 sr noet" >> /etc/apache2/sites-available/000-default.conf'
sudo a2ensite taxhub
#sudo a2enmod proxy
#sudo a2enmod proxy_http
# Installation et configuration de l'application TaxHub
./install_app.sh
sudo apache2ctl restart
##################
# GEONATURE-ATLAS
##################
# Installation de l'atlas avec l'utilisateur courant
echo "Téléchargement et installation de GeoNature-atlas ..."
cd /tmp
wget https://github.com/PnEcrins/GeoNature-atlas/archive/$atlas_release.zip
unzip $atlas_release.zip
rm $atlas_release.zip
mv GeoNature-atlas-$atlas_release /home/$monuser/atlas/
cd /home/$monuser/atlas
echo "Création de l'environnement virtuel de GeoNature-atlas ..."
virtualenv ./venv
. ./venv/bin/activate
echo "Installation des dépendances pour l'application GeoNature-atlas ..."
pip install -r requirements.txt
echo "Configuration de l'application GeoNature-atlas ..."
mkdir ./static/custom/images/
cp ./main/configuration/config.py.sample ./main/configuration/config.py
cp ./main/configuration/settings.ini.sample ./main/configuration/settings.ini
cp ./static/custom/templates/footer.html.sample ./static/custom/templates/footer.html
cp ./static/custom/templates/introduction.html.sample ./static/custom/templates/introduction.html
cp ./static/custom/templates/presentation.html.sample ./static/custom/templates/presentation.html
cp ./static/custom/templates/credits.html.sample ./static/custom/templates/credits.html
cp ./static/custom/templates/mentions-legales.html.sample ./static/custom/templates/mentions-legales.html
cp ./static/custom/custom.css.sample ./static/custom/custom.css
cp ./static/custom/glossaire.json.sample ./static/custom/glossaire.json
cp ./static/images/sample.favicon.ico ./static/custom/images/favicon.ico
cp ./static/images/sample.accueil-intro.jpg ./static/custom/images/accueil-intro.jpg
cp ./static/images/sample.logo-structure.png ./static/custom/images/logo-structure.png
cp ./static/images/sample.logo_patrimonial.png ./static/custom/images/logo_patrimonial.png
cp ./data/ref/communes.dbf.sample ./data/ref/communes.dbf
cp ./data/ref/communes.prj.sample ./data/ref/communes.prj
cp ./data/ref/communes.shp.sample ./data/ref/communes.shp
cp ./data/ref/communes.shx.sample ./data/ref/communes.shx
cp ./data/ref/territoire.dbf.sample ./data/ref/territoire.dbf
cp ./data/ref/territoire.prj.sample ./data/ref/territoire.prj
cp ./data/ref/territoire.shp.sample ./data/ref/territoire.shp
cp ./data/ref/territoire.shx.sample ./data/ref/territoire.shx
# Configuration des settings de GeoNature-atlas et création de la base de données
echo "Configuration et installation de la base de données ..."
sed -i "s/drop_apps_db=.*$/drop_apps_db=$drop_atlasdb/g" main/configuration/settings.ini
sed -i "s/drop_apps_db=.*$/drop_apps_db=$drop_atlasdb/g" main/configuration/settings.ini
sed -i "s/db_name=.*$/db_name=$atlasdb_name/g" main/configuration/settings.ini
sed -i "s/db_source_name=.*$/db_source_name=$geonaturedb_name/g" main/configuration/settings.ini
sed -i "s/user_pg=.*$/user_pg=$user_atlas/g" main/configuration/settings.ini
sed -i "s/user_pg_pass=.*$/user_pg_pass=$user_atlas_pass/g" main/configuration/settings.ini
sed -i "s/owner_atlas=.*$/owner_atlas=$user_pg/g" main/configuration/settings.ini
sed -i "s/owner_atlas_pass=.*$/owner_atlas_pass=$user_pg_pass/g" main/configuration/settings.ini
sed -i "s/db_source_host=.*$/db_source_host=$pg_host/g" main/configuration/settings.ini
sed -i "s/db_source_port=.*$/db_source_port=$pg_port/g" main/configuration/settings.ini
sed -i "s/atlas_source_user=.*$/atlas_source_user=$user_pg/g" main/configuration/settings.ini #TODO utiliser la variable $user_atlaset faire des GRANT select et usage pour geonatatlas sur la bd geonature
sed -i "s/atlas_source_pass=.*$/atlas_source_pass=$user_pg_pass/g" main/configuration/settings.ini #TODO utiliser la variable $user_atlas_pass
sed -i "s/metropole=.*$/metropole=$metropole/g" main/configuration/settings.ini
sed -i "s/taillemaille=.*$/taillemaille=$taillemaille/g" main/configuration/settings.ini
sed -i "s/taillemaille=.*$/taillemaille=$taillemaille/g" main/configuration/settings.ini
sed -i "s/MYUSERLINUX/$monuser/g" main/configuration/settings.ini
# Mise à jour de config.py
sed -i "s/database_connection =.*$/database_connection = \"postgresql:\/\/$user_atlas:$user_atlas_pass@$pg_host:$pg_port\/$atlasdb_name\"/g" main/configuration/config.py
sed -i "s/STRUCTURE = \".*$/STRUCTURE = \"$structure\"/g" main/configuration/config.py
sed -i "s/NOM_APPLICATION = \".*$/NOM_APPLICATION = \"$nom_application\"/g" main/configuration/config.py
sed -i "s/URL_APPLICATION =.*$/URL_APPLICATION = \"$url_atlas\"/g" main/configuration/config.py
sed -i "s/ID_GOOGLE_ANALYTICS =.*$/ID_GOOGLE_ANALYTICS = \"$id_google_analytics\"/g" main/configuration/config.py
sed -i "s/IGNAPIKEY =.*/IGNAPIKEY = \'$macleign\';/g" main/configuration/config.py
#sed -i "s/+IGNAPIKEY+/+$macleign+/g" main/configuration/config.py
sed -i "s/'LAT_LONG':.*$/\'LAT_LONG\': [$y, $x],/g" main/configuration/config.py
rm install_db.sh
wget https://raw.githubusercontent.com/Splendens/install_all_geonature_ubuntu16_04/master/install_atlas/install_db.sh
sudo chmod +x install_db.sh
sudo ./install_db.sh
# Configuration Apache de GeoNature-atlas
sudo rm /etc/apache2/sites-available/atlas.conf
sudo touch /etc/apache2/sites-available/atlas.conf
sudo sh -c 'echo "# Configuration de GeoNature-atlas" >> /etc/apache2/sites-available/atlas.conf'
sudo sh -c 'echo "WSGIScriptAlias /atlas \"/home/'$monuser'/atlas/atlas.wsgi\"" >> /etc/apache2/sites-available/atlas.conf'
sudo sh -c 'echo "<Directory \"/home/'$monuser'/atlas/\">" >> /etc/apache2/sites-available/atlas.conf'
sudo sh -c 'echo "WSGIApplicationGroup %{GLOBAL}" >> /etc/apache2/sites-available/atlas.conf'
sudo sh -c 'echo "WSGIScriptReloading On" >> /etc/apache2/sites-available/atlas.conf'
sudo sh -c 'echo "Order deny,allow" >> /etc/apache2/sites-available/atlas.conf'
sudo sh -c 'echo "Allow from all" >> /etc/apache2/sites-available/atlas.conf'
sudo sh -c 'echo "Require all granted" >> /etc/apache2/sites-available/atlas.conf'
sudo sh -c 'echo "</Directory>" >> /etc/apache2/sites-available/atlas.conf'
sudo a2ensite atlas
sudo apachectl restart
# Nettoyage
sudo rm /tmp/*.sql