1 | #!/bin/bash |
---|
2 | |
---|
3 | |
---|
4 | |
---|
5 | |
---|
6 | #zenity --info --title="Zero-jClic-Biblio-Installer" --timeout=4 --text="Welcome to JCLIC biblio installer, please be calm we are testing your net." > /dev/null 2>&1 & |
---|
7 | |
---|
8 | export TEXTDOMAIN="zero-lliurex-jclic-biblio-installer" |
---|
9 | |
---|
10 | #####################DEFINICION DE VARIABLES############################################## |
---|
11 | elteumestre="elteumestre_JClic_Infantil_Primaria_13 (4 GB)" |
---|
12 | murcia="Murcia_0809 (2 GB)" |
---|
13 | ratoli="JaumeBalmes_ Ratoli (3 GB)" |
---|
14 | |
---|
15 | #MARCA=$(gettext "Check") |
---|
16 | #LIBRERIAS=$(gettext "Available files") |
---|
17 | #TITULO=$(gettext "Jclic Libraries to download") |
---|
18 | #MSG_NO_INTERNET=$(gettext "No Internet Connection has been detected. Please, check it") |
---|
19 | |
---|
20 | IMAGENES_EL_TEU="http://www.lliurex.net/recursos/" |
---|
21 | PACK_EL_TEU="elteumestre_JClic_Infantil_Primaria_13.zip" |
---|
22 | IMAGENES_MURCIA="http://www.lliurex.net/recursos/" |
---|
23 | PACK_MURCIA="Murcia_0809.tar.gz" |
---|
24 | IMAGENES_RATOLI="http://www.lliurex.net/recursos/" |
---|
25 | PACK_RATOLI="JaumeBalmes_Ratoli.tar.gz" |
---|
26 | LOG=/tmp/jclic_biblio.log |
---|
27 | TEST="0" |
---|
28 | EXITO="1" |
---|
29 | SALIR="1" |
---|
30 | PATH_TO_JCLIC_PROJECTS="/net/server-sync/share/jclic-aula" |
---|
31 | |
---|
32 | ##################FUNCIONES#################################### |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | function test_file { |
---|
37 | #Funcion que comprueba si lo descargado esta bien o fue antes cancelado |
---|
38 | #Argumentos |
---|
39 | #$1: es la URL del fichero original, URL |
---|
40 | #$2: Es el nombre del fichero descargado por defecto en tmp, NAME |
---|
41 | |
---|
42 | #echo "Argumento 1, URL: $1" |
---|
43 | #echo "Argumento 2, NAME: $2" |
---|
44 | #Obtengo el tamaño original del fichero. |
---|
45 | LANGUAGE=en wget --spider -o /tmp/jclic_length.log "$1" |
---|
46 | LENGTH_ORIG=$( cat /tmp/jclic_length.log | grep Length | awk '{print $2}' ) |
---|
47 | |
---|
48 | |
---|
49 | #Obtengo el tamaño del fichero descargado |
---|
50 | LENGTH_DOWNLOAD=$( ls -l /tmp/$2 2>/dev/null | awk '{print $5}' ) |
---|
51 | |
---|
52 | #echo "LENGTH_ORIG is $LENGTH_ORIG" |
---|
53 | #echo "LENGTH_DOWNLOAD is $LENGTH_DOWNLOAD" |
---|
54 | #Comparo ambos valores |
---|
55 | if [ "$LENGTH_ORIG" != "$LENGTH_DOWNLOAD" ]; then |
---|
56 | echo "$2 cannot been installed in your system," |
---|
57 | echo "because you cancel it or the downloading has been a problem." |
---|
58 | echo "Start again the process if you want to install it and if the problem continues," |
---|
59 | echo "please contact with Lliurex-Team to resolve it." |
---|
60 | echo "" |
---|
61 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="$2 cannot been installed in your system because you cancel it or the downloading has been a problem. Start again the process if you want to install it and if the problem continues, please contact with Lliurex-Team to resolve it." > /dev/null 2>&1 & |
---|
62 | su -c "notify-send -t 3000 -u critical -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$2 cannot been installed in your system because you cancel it or the downloading has been a problem'" $USER > /dev/null 2>&1 |
---|
63 | TEST="0" |
---|
64 | else |
---|
65 | #La descarga es correcta entonces instalamos la biblioteca |
---|
66 | TEST="1" |
---|
67 | fi |
---|
68 | rm /tmp/jclic_length.log |
---|
69 | } |
---|
70 | |
---|
71 | |
---|
72 | function install_jclic { |
---|
73 | #Funcion de instalacion |
---|
74 | #$1: Argumento con el fichero a instalar, por defecto descargado en tmp, NAME |
---|
75 | #$2: Argumento para instalar la libreria jclic, PATH_TO_JCLIC_PROJECTS |
---|
76 | |
---|
77 | LOG_UN=/tmp/jclic_un.log |
---|
78 | touch $LOG_UN |
---|
79 | #Obtengo la extension del fichero, rar, zip.... |
---|
80 | |
---|
81 | EXT=$( ls /tmp/$1 | rev | cut -d "." -f 1 | rev ) |
---|
82 | echo "The file downloaded to install is $1 and the extension is $EXT" |
---|
83 | |
---|
84 | if [ ! -d "$2" ]; then |
---|
85 | mkdir -p "$2" |
---|
86 | fi |
---|
87 | |
---|
88 | #Compruebo que es una de las extensiones esperadas o salgo |
---|
89 | if [ "$EXT" != "zip" ] && [ "$EXT" != "gz" ]; then |
---|
90 | echo "$1 cannot been installed in your system," |
---|
91 | echo "because the extension is $EXT." |
---|
92 | echo "Jclic needs zip or tar extension to install it." |
---|
93 | echo "Start again the process if you want to install it and if the problem continues," |
---|
94 | echo "please contact with Lliurex-Team to resolve it." |
---|
95 | echo "" |
---|
96 | #Variable que indica que la extension es la que se esperaba y permitida, me vale para distinguir entre error de extension o de descompresion |
---|
97 | #Aqui es necesario tb inicializarla porque si ponemos dos o mas paquetes a descargar podria ocurrir que en una segunda pasada tuviese un valor no esperado |
---|
98 | EXITO="1" |
---|
99 | #Variable que nos da que hubo error en la extension y como el error ya se mostro no se muestra nada mas y se aborta el resto de la funcion que lo llamo. |
---|
100 | SALIR="0" |
---|
101 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="$1 cannot been installed in your system because the archive has the extension $EXT and Jclic needs ZIP or GZ extension. Start again the process if you want to install it and if the problem continues, please contact with Lliurex-Team to resolve it." > /dev/null 2>&1 & |
---|
102 | su -c "notify-send -t 3000 -u critical -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$1 cannot been installed in your system because the archive has the extension $EXT and Jclic needs ZIP or GZ extension'" $USER > /dev/null 2>&1 |
---|
103 | return |
---|
104 | else |
---|
105 | SALIR="1" |
---|
106 | EXITO="0" |
---|
107 | fi |
---|
108 | |
---|
109 | case $EXT in |
---|
110 | "zip") |
---|
111 | (unzip /tmp/$1 -d "$2" >> $LOG_UN ; if [ "$?" != 0 ] ; then EXITO="1"; else EXITO="0"; fi ; chmod -R 755 $2 ; rm $LOG_UN ) & |
---|
112 | #Mientras que el fichero de ayuda existe es que estamos descomprimiendo |
---|
113 | #Cuando ya no exista saldremos del while |
---|
114 | while [ -f $LOG_UN ]; do |
---|
115 | echo "The file is a ZIP.....uncompresing" |
---|
116 | #En la variable PERCENT almacenamos el tanto por cien que llevamos de descarga |
---|
117 | #accediento a la ultima linea escrita en el fichero de ayuda y seleccionando solo el dato que necesitamos. |
---|
118 | VAR=$( tail -1 $LOG_UN 2>/dev/null ) |
---|
119 | #Hacemos echo de los datos que necesita el zenity |
---|
120 | echo "#Installing $1.......$VAR" | cut -c1-85 |
---|
121 | #por ultimo entubamos la salida al zenity progress para que nos muestre el resultado en pantalla |
---|
122 | done | zenity --progress --auto-close --pulsate --width 500 --title="Zero-jClic-Biblio-Installer" --no-cancel > /dev/null 2>&1 |
---|
123 | |
---|
124 | ;; |
---|
125 | "gz") |
---|
126 | (tar -xvf /tmp/$1 -C $2 >> $LOG_UN ; if [ "$?" != 0 ] ; then EXITO="1"; else EXITO="0"; fi ; chmod -R 755 $2 ; rm $LOG_UN ) & |
---|
127 | #Mientras que el fichero de ayuda existe es que estamos descomprimiendo |
---|
128 | #Cuando ya no exista saldremos del while |
---|
129 | echo "The file is a TAR.....uncompresing" |
---|
130 | while [ -f $LOG_UN ]; do |
---|
131 | #En la variable PERCENT almacenamos el tanto por cien que llevamos de descarga |
---|
132 | #accediento a la ultima linea escrita en el fichero de ayuda y seleccionando solo el dato que necesitamos. |
---|
133 | VAR=$( tail -1 $LOG_UN 2>/dev/null ) |
---|
134 | #Hacemos echo de los datos que necesita el zenity |
---|
135 | echo "#Installing $1.......$VAR" | cut -c1-85 |
---|
136 | #por ultimo entubamos la salida al zenity progress para que nos muestre el resultado en pantalla |
---|
137 | done | zenity --progress --auto-close --pulsate --width 500 --title="Zero-jClic-Biblio-Installer" --no-cancel > /dev/null 2>&1 |
---|
138 | |
---|
139 | ;; |
---|
140 | esac |
---|
141 | } |
---|
142 | |
---|
143 | |
---|
144 | |
---|
145 | function main { |
---|
146 | |
---|
147 | #ARGUMENTOS NECESARIOS |
---|
148 | #Arg1: Instalar o desinstalar el paquete, install or remove |
---|
149 | #Arg2: Paquete a instalar, elteumestre, murcia,ratoli |
---|
150 | #Arg3: Path donde se instalara, segun sea server o desktop |
---|
151 | |
---|
152 | |
---|
153 | #DEFINO LOS CASOS A INSTALAR/REMOVE SEGUN SE SELECCIONEN |
---|
154 | |
---|
155 | case "$2" in |
---|
156 | "elteumestre") |
---|
157 | |
---|
158 | #inicializo variables |
---|
159 | PATH_TO_JCLIC_PROJECTS=$3 |
---|
160 | PATH_INSTALLED="$(find $3 -maxdepth 1 -mindepth 1 -xtype d -name '*mestre*')" |
---|
161 | #Creo la URL para la descarga |
---|
162 | URL="$IMAGENES_EL_TEU$PACK_EL_TEU" |
---|
163 | PACK_SELECT="$elteumestre" |
---|
164 | |
---|
165 | if [ "$1" = "install" ]; then |
---|
166 | if [ ! -d "$PATH_INSTALLED" ]; then |
---|
167 | echo "" |
---|
168 | echo "" |
---|
169 | echo "Select to install $PACK_SELECT in $3$PATH_INSTALLED" |
---|
170 | echo "--------------------------------------------------------------" |
---|
171 | |
---|
172 | |
---|
173 | #Compruebo si la URL es operativa |
---|
174 | if wget --spider -o $LOG "$URL"; then |
---|
175 | |
---|
176 | echo "URL $URL exists, download it......." |
---|
177 | rm $LOG > /dev/null 2>&1 |
---|
178 | #Obtengo el nombre del fichero a descargar |
---|
179 | NAME=$(echo $URL | rev | cut -d "/" -f1 | rev) |
---|
180 | if [ -f /tmp/$NAME ]; then |
---|
181 | #El fichero fue descargado anteriormente, lo borrro, para descargarlo de nuevo. |
---|
182 | echo "Delete /tmp/$NAME because it was downloaded before" |
---|
183 | rm /tmp/$NAME* |
---|
184 | fi |
---|
185 | |
---|
186 | #Creo la variable aux que tiene la instruccion de descarga y la descargo como usuario de la maquina. |
---|
187 | aux="zero-lliurex-wget $URL /tmp" |
---|
188 | su $USER -c "$aux" |
---|
189 | |
---|
190 | # testeo si lo descargado esta bien |
---|
191 | test_file "$URL" "$NAME" |
---|
192 | |
---|
193 | #Instalo la libreria descargada si todo fue bien anteriormente. |
---|
194 | if [ "$TEST" = "1" ]; then |
---|
195 | echo "Install NAME: $NAME in PATH_TO_JCLIC_PROJECTS: $PATH_TO_JCLIC_PROJECTS" |
---|
196 | install_jclic $NAME $PATH_TO_JCLIC_PROJECTS |
---|
197 | |
---|
198 | if [ "$SALIR" = "0" ]; then |
---|
199 | #salgo de la funcion ya que fallo la extension del fichero, no era la esperada |
---|
200 | echo "Error in the extension fo the file downloaded" |
---|
201 | else |
---|
202 | #La extension del fichero era la correcta |
---|
203 | if [ "$EXITO" = "0" ]; then |
---|
204 | #Todo fue bien |
---|
205 | #Borro la libreria descargada una vez instalada |
---|
206 | rm /tmp/$NAME* |
---|
207 | echo "Congratulations!!!!" |
---|
208 | echo "$PACK_SELECT has been installed in your system the library in $PATH_TO_JCLIC_PROJECTS" |
---|
209 | echo "Now you can enjoy it." |
---|
210 | echo "" |
---|
211 | su -c "notify-send -t 3000 -u critical -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$PACK_SELECT has been installed in your system the library in $PATH_TO_JCLIC_PROJECTS'" $USER |
---|
212 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="$PACK_SELECT has been installed in your system the library in $PATH_TO_JCLIC_PROJECTS" > /dev/null 2>&1 & |
---|
213 | else |
---|
214 | #fallo al descomprimir la biblioteca |
---|
215 | su -c "notify-send -t 3000 -u critical -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$PACK_SELECT cannot be installed in your system, because the uncompressing fail. Please download it again and if the error persist contact with Lliurex Team'" $USER |
---|
216 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="$PACK_SELECT cannot be installed in your system, because the uncompressing fail. Please download it again and if the error persist contact with Lliurex Team" > /dev/null 2>&1 & |
---|
217 | fi |
---|
218 | fi |
---|
219 | fi |
---|
220 | |
---|
221 | else |
---|
222 | #La URL no es accesible, salida. |
---|
223 | echo "You select install $PACK_SELECT," |
---|
224 | echo "it needs this URL $URL and it is not accesible." |
---|
225 | echo "Please contact with Lliurex-Team" |
---|
226 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="You select install $PACK_SELECT, sorry but your URL $URL is not accesible, contact with Lliurex-Team and send this file $LOG" > /dev/null 2>&1 & |
---|
227 | fi |
---|
228 | fi |
---|
229 | fi |
---|
230 | if [ "$1" = "remove" ]; then |
---|
231 | |
---|
232 | if [ -d "$PATH_INSTALLED" ]; then |
---|
233 | echo "" |
---|
234 | echo "" |
---|
235 | echo "Select to remove $PACK_SELECT" |
---|
236 | echo "--------------------------------------------------------------" |
---|
237 | echo "$PACK_SELECT has been removed from your system in $PATH_INSTALLED succesfully" |
---|
238 | rm -R "$PATH_INSTALLED" | zenity --progress --auto-close --pulsate --width 500 --title="Zero-jClic-Biblio-Installer" --text="Removing $PACK_SELECT, please wait........." --no-cancel > /dev/null 2>&1 |
---|
239 | su -c "notify-send -t 3000 -u critical -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$PACK_SELECT has been removed from your system succesfully'" $USER |
---|
240 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="$PACK_SELECT has been removed from your system succesfully" > /dev/null 2>&1 & |
---|
241 | fi |
---|
242 | fi |
---|
243 | |
---|
244 | ;; |
---|
245 | |
---|
246 | |
---|
247 | "murcia") |
---|
248 | |
---|
249 | #inicializo variables |
---|
250 | PATH_TO_JCLIC_PROJECTS=$3 |
---|
251 | PATH_INSTALLED="$(find $3 -maxdepth 1 -mindepth 1 -xtype d -name '*urcia*')" |
---|
252 | #Creo la URL para la descarga |
---|
253 | URL="$IMAGENES_MURCIA$PACK_MURCIA" |
---|
254 | PACK_SELECT="$murcia" |
---|
255 | |
---|
256 | if [ "$1" = "install" ]; then |
---|
257 | if [ ! -d "$PATH_INSTALLED" ]; then |
---|
258 | echo "" |
---|
259 | echo "" |
---|
260 | echo "Select to install $PACK_SELECT in $3$PATH_INSTALLED" |
---|
261 | echo "--------------------------------------------------------------" |
---|
262 | |
---|
263 | |
---|
264 | #Compruebo si la URL es operativa |
---|
265 | if wget --spider -o $LOG "$URL"; then |
---|
266 | |
---|
267 | echo "URL $URL exists, download it......." |
---|
268 | rm $LOG > /dev/null 2>&1 |
---|
269 | #Obtengo el nombre del fichero a descargar |
---|
270 | NAME=$(echo $URL | rev | cut -d "/" -f1 | rev) |
---|
271 | if [ -f /tmp/$NAME ]; then |
---|
272 | #El fichero fue descargado anteriormente, lo borrro, para descargarlo de nuevo. |
---|
273 | echo "Delete /tmp/$NAME because it was downloaded before" |
---|
274 | rm /tmp/$NAME* |
---|
275 | fi |
---|
276 | |
---|
277 | #Creo la variable aux que tiene la instruccion de descarga y la descargo como usuario de la maquina. |
---|
278 | aux="zero-lliurex-wget $URL /tmp" |
---|
279 | su $USER -c "$aux" |
---|
280 | |
---|
281 | # testeo si lo descargado esta bien |
---|
282 | test_file "$URL" "$NAME" |
---|
283 | |
---|
284 | #Instalo la libreria descargada si todo fue bien anteriormente. |
---|
285 | if [ "$TEST" = "1" ]; then |
---|
286 | echo "Install NAME: $NAME in PATH_TO_JCLIC_PROJECTS: $PATH_TO_JCLIC_PROJECTS" |
---|
287 | install_jclic $NAME $PATH_TO_JCLIC_PROJECTS |
---|
288 | |
---|
289 | if [ "$SALIR" = "0" ]; then |
---|
290 | #salgo de la funcion ya que fallo la extension del fichero, no era la esperada |
---|
291 | echo "" |
---|
292 | else |
---|
293 | #La extension del fichero era la correcta |
---|
294 | if [ "$EXITO" = "0" ]; then |
---|
295 | #Todo fue bien |
---|
296 | #Borro la libreria descargada una vez instalada |
---|
297 | rm /tmp/$NAME* |
---|
298 | #CAMBIO EL NOMBRE AL DIRECTORIO LOS ESPACIOS NO SE LLEVAN BIEN EN EL JCLIC |
---|
299 | PATH_INSTALLED="$(/usr/bin/find $3 -maxdepth 1 -mindepth 1 -xtype d -name '*urcia*')" |
---|
300 | echo "_________________________________________________" |
---|
301 | echo "" |
---|
302 | echo "Estaba instalado en $PATH_INSTALLED y se movera a $PATH_TO_JCLIC_PROJECTS/Murcia" |
---|
303 | mv "$PATH_INSTALLED" "$PATH_TO_JCLIC_PROJECTS/Murcia" |
---|
304 | echo "_________________________________________________" |
---|
305 | echo |
---|
306 | echo "Congratulations!!!!" |
---|
307 | echo "$PACK_SELECT has been installed in your system the library in $PATH_TO_JCLIC_PROJECTS" |
---|
308 | echo "Now you can enjoy it." |
---|
309 | echo "" |
---|
310 | su -c "notify-send -t 3000 -u critical -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$PACK_SELECT has been installed in your system the library in $PATH_TO_JCLIC_PROJECTS'" $USER |
---|
311 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="$PACK_SELECT has been installed in your system the library in $PATH_TO_JCLIC_PROJECTS" > /dev/null 2>&1 & |
---|
312 | else |
---|
313 | #fallo al descomprimir la biblioteca |
---|
314 | su -c "notify-send -t 3000 -u critical -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$PACK_SELECT cannot be installed in your system, because the uncompressing fail. Please download it again and if the error persist contact with Lliurex Team'" $USER |
---|
315 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="$PACK_SELECT cannot be installed in your system, because the uncompressing fail. Please download it again and if the error persist contact with Lliurex Team" > /dev/null 2>&1 & |
---|
316 | fi |
---|
317 | fi |
---|
318 | fi |
---|
319 | |
---|
320 | else |
---|
321 | #La URL no es accesible, salida. |
---|
322 | echo "You select install $PACK_SELECT," |
---|
323 | echo "it needs this URL $URL and it is not accesible." |
---|
324 | echo "Please contact with Lliurex-Team" |
---|
325 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="You select install $PACK_SELECT, sorry but your URL $URL is not accesible, contact with Lliurex-Team and send this file $LOG" > /dev/null 2>&1 & |
---|
326 | fi |
---|
327 | fi |
---|
328 | fi |
---|
329 | if [ "$1" = "remove" ]; then |
---|
330 | |
---|
331 | if [ -d "$PATH_INSTALLED" ]; then |
---|
332 | echo "" |
---|
333 | echo "" |
---|
334 | echo "Select to remove $PACK_SELECT" |
---|
335 | echo "--------------------------------------------------------------" |
---|
336 | echo "$PACK_SELECT has been removed from your system in $PATH_INSTALLED succesfully" |
---|
337 | rm -R "$PATH_INSTALLED" | zenity --progress --auto-close --pulsate --width 500 --title="Zero-jClic-Biblio-Installer" --text="Removing $PACK_SELECT, please wait........." --no-cancel > /dev/null 2>&1 |
---|
338 | su -c "notify-send -t 3000 -u critical -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$PACK_SELECT has been removed from your system succesfully'" $USER |
---|
339 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="$PACK_SELECT has been removed from your system succesfully" > /dev/null 2>&1 & |
---|
340 | fi |
---|
341 | fi |
---|
342 | |
---|
343 | ;; |
---|
344 | |
---|
345 | "ratoli") |
---|
346 | |
---|
347 | #inicializo variables para el caso del borrado |
---|
348 | PATH_TO_JCLIC_PROJECTS=$3 |
---|
349 | PATH_INSTALLED="$(find $3 -maxdepth 1 -mindepth 1 -xtype d -name 'ratoli')" |
---|
350 | #Creo la URL para la descarga |
---|
351 | URL="$IMAGENES_RATOLI$PACK_RATOLI" |
---|
352 | PACK_SELECT="$ratoli" |
---|
353 | if [ "$1" = "install" ]; then |
---|
354 | if [ ! -d "$PATH_INSTALLED" ]; then |
---|
355 | echo "" |
---|
356 | echo "" |
---|
357 | echo "Select to install $PACK_SELECT in $3$PATH_INSTALLED" |
---|
358 | echo "--------------------------------------------------------------" |
---|
359 | |
---|
360 | |
---|
361 | #Compruebo si la URL es operativa |
---|
362 | if wget --spider -o $LOG "$URL"; then |
---|
363 | |
---|
364 | echo "URL $URL exists, download it......." |
---|
365 | rm $LOG > /dev/null 2>&1 |
---|
366 | #Obtengo el nombre del fichero a descargar |
---|
367 | NAME=$(echo $URL | rev | cut -d "/" -f1 | rev) |
---|
368 | if [ -f /tmp/$NAME ]; then |
---|
369 | #El fichero fue descargado anteriormente, lo borrro, para descargarlo de nuevo. |
---|
370 | echo "Delete /tmp/$NAME because it was downloaded before" |
---|
371 | rm /tmp/$NAME* |
---|
372 | fi |
---|
373 | |
---|
374 | #Creo la variable aux que tiene la instruccion de descarga y la descargo como usuario de la maquina. |
---|
375 | aux="zero-lliurex-wget $URL /tmp" |
---|
376 | su $USER -c "$aux" |
---|
377 | |
---|
378 | # testeo si lo descargado esta bien |
---|
379 | test_file "$URL" "$NAME" |
---|
380 | |
---|
381 | #Instalo la libreria descargada si todo fue bien anteriormente. |
---|
382 | if [ "$TEST" = "1" ]; then |
---|
383 | echo "Install NAME: $NAME in PATH_TO_JCLIC_PROJECTS: $PATH_TO_JCLIC_PROJECTS" |
---|
384 | #install_jclic $NAME $PATH_TO_JCLIC_PROJECTS |
---|
385 | mkdir /tmp/ratoli |
---|
386 | install_jclic $NAME /tmp/ratoli |
---|
387 | |
---|
388 | if [ "$SALIR" = "0" ]; then |
---|
389 | #salgo de la funcion ya que fallo la extension del fichero, no era la esperada |
---|
390 | echo "" |
---|
391 | else |
---|
392 | #La extension del fichero era la correcta |
---|
393 | if [ "$EXITO" = "0" ]; then |
---|
394 | #Todo fue bien muevo la libreria a su sitio |
---|
395 | ( mv /tmp/ratoli/jclic /tmp/ratoli/ratoli ; mv /tmp/ratoli/ratoli $NAME $PATH_TO_JCLIC_PROJECTS ) | zenity --progress --auto-close --pulsate --width 500 --title="Zero-jClic-Biblio-Installer" --text="Moving files, wait please......." --no-cancel > /dev/null 2>&1 |
---|
396 | |
---|
397 | #Borro la libreria descargada una vez instalada |
---|
398 | rm /tmp/$NAME* |
---|
399 | echo "Congratulations!!!!" |
---|
400 | echo "$PACK_SELECT has been installed in your system the library in $PATH_TO_JCLIC_PROJECTS" |
---|
401 | echo "Now you can enjoy it." |
---|
402 | echo "" |
---|
403 | su -c "notify-send -t 3000 -u critical -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$PACK_SELECT has been installed in your system the library in $PATH_TO_JCLIC_PROJECTS'" $USER |
---|
404 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="$PACK_SELECT has been installed in your system the library in $PATH_TO_JCLIC_PROJECTS" > /dev/null 2>&1 & |
---|
405 | else |
---|
406 | #fallo al descomprimir la biblioteca |
---|
407 | su -c "notify-send -t 3000 -u critical -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$PACK_SELECT cannot be installed in your system, because the uncompressing fail. Please download it again and if the error persist contact with Lliurex Team'" $USER |
---|
408 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="$PACK_SELECT cannot be installed in your system, because the uncompressing fail. Please download it again and if the error persist contact with Lliurex Team" > /dev/null 2>&1 & |
---|
409 | fi |
---|
410 | fi |
---|
411 | fi |
---|
412 | |
---|
413 | else |
---|
414 | #La URL no es accesible, salida. |
---|
415 | echo "You select install $PACK_SELECT," |
---|
416 | echo "it needs this URL $URL and it is not accesible." |
---|
417 | echo "Please contact with Lliurex-Team" |
---|
418 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="You select install $PACK_SELECT, sorry but your URL $URL is not accesible, contact with Lliurex-Team and send this file $LOG" > /dev/null 2>&1 & |
---|
419 | fi |
---|
420 | fi |
---|
421 | fi |
---|
422 | if [ "$1" = "remove" ]; then |
---|
423 | |
---|
424 | if [ -d "$PATH_INSTALLED" ]; then |
---|
425 | echo "" |
---|
426 | echo "" |
---|
427 | echo "Select to remove $PACK_SELECT" |
---|
428 | echo "--------------------------------------------------------------" |
---|
429 | echo "$PACK_SELECT has been removed from your system in $PATH_INSTALLED succesfully" |
---|
430 | rm -R "$PATH_INSTALLED" | zenity --progress --auto-close --pulsate --width 500 --title="Zero-jClic-Biblio-Installer" --text="Removing $PACK_SELECT, please wait........." --no-cancel > /dev/null 2>&1 |
---|
431 | su -c "notify-send -t 3000 -u critical -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$PACK_SELECT has been removed from your system succesfully'" $USER |
---|
432 | zenity --info --title="Zero-jClic-Biblio-Installer" --text="$PACK_SELECT has been removed from your system succesfully" > /dev/null 2>&1 & |
---|
433 | fi |
---|
434 | fi |
---|
435 | |
---|
436 | ;; |
---|
437 | |
---|
438 | esac |
---|
439 | } |
---|
440 | |
---|
441 | |
---|
442 | |
---|
443 | |
---|
444 | |
---|
445 | |
---|
446 | |
---|
447 | #########################MAIN PROGRAM ############################## |
---|
448 | #zero-center add-pulsating-color zero-lliurex-jclic-biblio-installer |
---|
449 | #$1 install ::: remove :::: Argument to install or remove this biblio jclic |
---|
450 | #$2 elteumestre ::: murcia :::: ratoli ::: Argument to jclic name |
---|
451 | #$3 path_jclic |
---|
452 | |
---|
453 | main $1 $2 $3 |
---|
454 | #zero-center remove-pulsating-color zero-lliurex-jclic-biblio-installer |
---|
455 | |
---|
456 | exit 0 |
---|