TiledViz
Loading...
Searching...
No Matches
/github/workspace/install.sh
1#!/bin/bash
2
3UseLastEnv=$1
4
5echo "#==== Tiledviz installation script. ==="
6echo "If you want to use graphical installation, you need to install zenity package on your system,"
7echo "and set installX11=true in envTiledViz on your TiledViz source root, OK ?"
8#read OK
9
10source ./envTiledViz
11
12# if asked installX11 in ./envTiledViz rerun with graphical progress bar.
13if ( $installX11 ) && [ X"$GraphicalInstall" != Xtrue ]; then
14 export GraphicalInstall=true
15 echo "Restart with graphical progression bar."
16 sleep 3
17 ( ./install.sh $UseLastEnv ) | zenity --progress --title="Progress Status" --text="First Task" --percentage=0 --auto-kill
18 #--auto-close
19 exit 0
20fi
21
22echo "1"
23
24echo "# Test Docker rights"
25echo $(docker ps -a)
26echo "5"
27
28# Build Virtualenv for TVSecure
29# if UseLastEnv is null, build a new environement
30if [ X"$UseLastEnv" == X"" ]; then
31 echo "#==== Build new Virtualenv for TVSecure ===="
32 export DATE=$(date +%F_%H-%M-%S)
33 echo "#DATE=$DATE"
34
35 mkdir TiledVizEnv_${DATE}
36 python3 -m venv TiledVizEnv_${DATE}
37 source TiledVizEnv_${DATE}/bin/activate
38 echo "8"
39
40 echo "#==== Copy TiledViz env in .cache ===="
41 [ ! -d $HOME/.cache ] && mkdir $HOME/.cache
42 sed -e "s&DATE=.*&DATE=$DATE&" envTiledViz > $HOME/.cache/envTiledViz
43 chmod 600 $HOME/.cache/envTiledViz
44 echo "9"
45
46 ls -la $HOME/.cache/envTiledViz
47 source $HOME/.cache/envTiledViz
48 echo "# Build Env OK."
49
50else
51 echo "#==== Retreive old configuration ===="
52 OLDENV=$(find . -maxdepth 1 -type d -name "TiledVizEnv_*" |tail -1)
53 export DATE_ENV=$(echo $OLDENV |sed -e 's&\./TiledVizEnv_&&')
54 source $OLDENV/bin/activate
55 echo "8"
56
57 ls -la $HOME/.cache/envTiledViz
58 source $HOME/.cache/envTiledViz
59 if [ ${DATE_ENV} != ${DATE} ]; then
60 echo "#Error restart install : DATEs not equal ${DATE_ENV} != ${DATE}."
61 sleep 10
62 exit 1
63 fi
64 echo "# Retrieve Env OK."
65fi
66
67echo "10"
68
69echo "#===== Enable FirewallT Tiledviz ====="
70
71if ( $installX11 ); then
72 zenity --question --title "TiledViz firewall" --text " Activate firewallT for Tiledviz ?"
73 elsefirewallT=$?
74 [[ $firewallT == 0 ]] && firewallT=y || firewallT=n
75else
76 echo "Activate firewallT for Tiledviz ? : ('n' or 'y')"
77 read -s firewallT;
78 [[ $firewallT == y || $firewallT == n ]] && echo "Valid Input" || echo "Invalid Input"
79fi
80
81echo "#==== Install environment ===="
82TiledVizEnv_$DATE/bin/python3 -m pip install --upgrade pip
83# TiledViz packages
84pip3 install -r requirements.txt
85
86echo "20"
87
88# Get noVNC
89echo "#==== Get noVNC ===="
90pushd TVWeb
91./install_noVNC
92echo "25"
93popd
94echo "27"
95
96echo "#==== Get websockify ===="
97pushd TVConnections
98git clone https://github.com/novnc/websockify
99popd
100
101echo "30"
102
103# Launch postgresql docker
104echo "#==== Prepare postgresql docker ===="
105if ( $installX11 ); then
106 Outz=$(zenity --width=600 --forms --title="Postgres DB" \
107 --text="Create Postgres Docker."\
108 --add-entry="Docker name (default: ${postgresNAME})" --add-entry="External PORT (default: ${POSTGRES_PORT})" --add-password="Password (forbiden '@', '&', '/', '|')")
109 $(echo $Outz | sed -e 's&\‍([^|]*\‍)|\‍([^|]*\‍)|\‍([^|]*\‍)&export POSTG_NAME="\1" export POSTG_PORT="\2" export password="\3"&')
110else
111 echo "Please give the Docker name of PostGresQL DB (default: ${postgresNAME})."
112 read POSTG_NAME;
113 echo "Please give its external PORT (default: ${POSTGRES_PORT})."
114 read POSTG_PORT;
115
116 echo "Please give a password for your postgresql DB : (forbiden '@', '/', '|' !)"
117 read -s password
118fi
119[ X"$POSTG_NAME" == X ] && export POSTG_NAME=$postgresNAME
120[ X"$POSTG_PORT" == X ] && export POSTG_PORT=$POSTGRES_PORT
121replpass=$( echo $password | sed -e "s|\&|\\\&|g" -e 's|"||g' )
122
123sed -e "s&${postgresNAME}&$POSTG_NAME&" \
124 -e "s&${POSTGRES_PORT}&$POSTG_PORT&" \
125 -e "s|your_postgres_password|$replpass|" \
126 -i $HOME/.cache/envTiledViz
127echo "32"
128
129echo "#==== Copy tiledViz.conf in $HOME/.tiledviz cache dir ===="
130mkdir $HOME/.tiledviz
131cp tiledviz.conf $HOME/.tiledviz
132[[ $firewallT == y ]] && sed -e "s|FirewallT=False|FirewallT=True|" -i $HOME/.tiledviz/tiledviz.conf
133echo "33"
134
135echo "#=== Web Server URL ==="
136if ( $installX11 ); then
137 webserver=$(zenity --forms --title="Web server informations" --text="SSL web server.domain name" --add-entry="Server name" --add-entry="Domain extension" )
138 $(echo $webserver |sed -e 's&\‍([^|]*\‍)|\‍([^|]*\‍)&export SERVER_NAME="\1" export DOMAIN="\2"&')
139else
140 echo "Please give a SERVER.DOMAIN for your SSL web server"
141 read myweb;
142 IFS='.' read -r -a webline <<<$myweb
143
144 # Array slice
145 serv="${webline[@]: 0:$((${#webline[*]}-2))}"
146 SERVER_NAME=$(echo $serv |sed -e "s/ /./g")
147 DOMAIN=${webline[${#webline[*]}-2]}.${webline[${#webline[*]}-1]}
148fi
149
150echo "35"
151
152
153if ( $installX11 ); then
154 Outz=$(zenity --width=600 --forms --title="Web connections informations" \
155 --text="SSL, SMTP, MAIL ( outgoing mail server for 2FA )."\
156 --add-entry="SSL PUBLIC key path" --add-entry="SSL PRIVATE key path" --add-entry="TiledViz email.")
157 $(echo $Outz | sed -e 's&\‍([^|]*\‍)|\‍([^|]*\‍)|\‍([^|]*\‍)&export SSLpublic="\1" export SSLprivate="\2" export FROM_EMAIL="\3"&')
158
159 Outz=$(zenity --width=600 --forms --title="SMTP server for some TiledSet cases" \
160 --add-entry="SMTP server address (optionnal)" \
161 --add-entry="SMTP server PORT" \
162 --add-entry="SMTP server username" \
163 --add-password="SMTP server password" )
164 $(echo $Outz | sed -e 's&\‍([^|]*\‍)|\‍([^|]*\‍)|\‍([^|]*\‍)|\‍([^|]*\‍)&export SMTP_SERVER="\1" export SMTP_PORT="\2" export SMTP_USERNAME="\3" export SMTP_PASSWORD="\4"&')
165
166 Outz=$(zenity --question --title "SMTP server" --text "SSL option ?" )
167 SMTP_USE_SSL=$( [[ $? == 0 ]] && echo true || echo false )
168 Outz=$(zenity --question --title "SMTP server" --text "TLS option ?" )
169 SMTP_USE_TLS=$( [[ $? == 0 ]] && echo true || echo false )
170
171 Outz=$(zenity --width=600 --forms --title="IMAP and NTP (optionnal)" \
172 --text="IMAP server ( the ingoing mail server ) | NTP server ( time server )" \
173 --add-entry="IMAP server address" \
174 --add-entry="IMAP server PORT " \
175 --add-entry="NTP server address" )
176 $(echo $Outz | sed -e 's&\‍([^|]*\‍)|\‍([^|]*\‍)|\‍([^|]*\‍)&export IMAP_SERVER="\1" export IMAP_PORT="\2" export NTP="\3"&')
177
178 echo "#$SSLpublic $SSLprivate $SMTP_SERVER $SMTP_PORT $SMTP_USE_SSL $SMTP_USE_TLS $SMTP_USERNAME $SMTP_PASSWORD $FROM_EMAIL $IMAP_SERVER $IMAP_PORT $NTP"
179else
180 echo "Please give the PUBLIC SSL key PATH."
181 read SSLpublic;
182 echo "Please give the PRIVATE SSL key PATH."
183 read SSLprivate;
184
185 echo "Please give your SMTP server address - the outgoing mail server."
186 read SMTP_SERVER;
187 echo "Please give your SMTP PORT address - for the outgoing mail server."
188 read SMTP_PORT;
189 echo "Please give your SMTP SSL option - for the outgoing mail server."
190 read SMTP_USE_SSL;
191 echo "Please give your SMTP TLS option - for the outgoing mail server."
192 read SMTP_USE_TLS;
193 echo "Please give your SMTP user name - for the outgoing mail server."
194 read SMTP_USERNAME;
195 echo "Please give your SMTP password - for the outgoing mail server."
196 read SMTP_PASSWORD;
197 echo "Please give this TiledViz email - for the outgoing mail server."
198 read FROM_EMAIL;
199 echo "Please give your IMAP server address - the ingoing mail server."
200 read IMAP_SERVER;
201 echo "Please give your IMAP PORT address - for the ingoing mail server."
202 read IMAP_PORT;
203
204 echo "Please give your NTP server address - the time server."
205 read NTP;
206fi
207SMTP_PASSWORD=$( echo $SMTP_PASSWORD | sed -e "s|\&|\\\&|g" -e 's|"||g' )
208
209sed -e "s&_SERVER_NAME_&$SERVER_NAME&" \
210 -e "s&_DOMAIN_&$DOMAIN&" \
211 -e "s&_SSLpublic_&$SSLpublic&" \
212 -e "s&_SSLprivate_&$SSLprivate&" \
213 -e "s&_NTP_&$NTP&" \
214 -e "s&_SMTP_SERVER_&$SMTP_SERVER&" \
215 -e "s&_SMTP_PORT_&$SMTP_PORT&" \
216 -e "s&_SMTP_USE_TLS_&$SMTP_USE_TLS&" \
217 -e "s&_SMTP_USE_SSL_&$SMTP_USE_SSL&" \
218 -e "s&_SMTP_USERNAME_&$SMTP_USERNAME&" \
219 -e "s&_SMTP_PASSWORD_&$SMTP_PASSWORD&" \
220 -e "s&_FROM_EMAIL_&$FROM_EMAIL&" \
221 -e "s&_IMAP_SERVER_&$IMAP_SERVER&" \
222 -e "s&_IMAP_PORT_&$IMAP_PORT&" \
223 -i $HOME/.cache/envTiledViz
224
225echo "40"
226
227# ==========================================================
228echo "==== Start PostgreSQL ===="
229./start_postgres
230echo "50"
231
232sleep 2
233
234echo "#==== Build Docker images ===="
235echo "#===== build connection Docker ====="
236TVConnections/build_connect
237
238echo "60"
239
240echo "#===== build Flask Docker ====="
241TVWeb/FlaskDocker/build_flaskdock
242
243echo "70"
244
245echo "#===== build HPC images : ====="
246echo "#====== Magiea connection client ======"
247
248TVConnections/build_mageia_latest
249TVConnections/build_mageia8
250
251echo "80"
252
253echo "#====== Ubuntu connection client ======"
254TVConnections/build_tileubuntu
255
256echo "90"
257
258echo "#====== End build dockers ======"
259#mv ${HOME}/tmp/postgresql_$DATE TVDatabase/postgresql
260
261if [[ $firewallT == y ]]; then
262 echo "#====== Activate FirewallT ======"
263 # Capabilites pour executer python sans sudo (setcap -r pour l'enlever)
264 echo "Set capabilites on python"
265 sudo setcap cap_net_admin=eip $(realpath $(which python))
266fi
267echo "100"
268
269# TODO : git clone Countdown 360:
270#cd TVWeb/apps/static/dist/js
271#git clone https://github.com/johnschult/jquery.countdown360.git
272
273
274echo "# All finished."