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