Changeset 2053


Ignore:
Timestamp:
Jun 29, 2016, 1:57:49 PM (3 years ago)
Author:
Juanma
Message:

Added error checking to apt/dpkg commands

File:
1 edited

Legend:

Unmodified
Added
Removed
  • zero-center/trunk/fuentes/install-files/usr/bin/zero-installer

    r1294 r2053  
    88MSG_REMOVED=$(gettext "Removed")
    99MSG_FINISH_INSTALLED=$(gettext "has been INSTALLED in your system, and you can view the log in")
     10MSG_FINISH_UNINSTALLED=$(gettext "has NOT been INSTALLED in your system, and you can view the log in")
    1011MSG_FINISH_SYSTEM1=$(gettext "has been")
     12MSG_FINISH_ERROR=$(gettext "has NOT been")
    1113MSG_FINISH_SYSTEM=$(gettext "in your system, and you can view the log in")
    1214
     
    6062                        NAME_PACK=$(echo $2 | rev | cut -d "/" -f1 | rev)                       
    6163                        #En segundo plano realizaremos la instalacion del paquete almacenando su salida en nuestro log, eliminando nuestro fichero ayuda para salir del bucle.
    62                         (dpkg -i $2 >> /tmp/zero-installer.log ; rm /tmp/zero-install.log) &
    63                         echo "................................................................................." >> /tmp/zero-installer.log
     64                        TEST=`(dpkg -i $2 >> /tmp/zero-installer.log ; echo $?; rm /tmp/zero-install.log) &`
    6465                        echo " " >> /tmp/zero-installer.log
    6566                        echo "Zero-center-------Your instruction is----------dpkg -i $2" >> /tmp/zero-installer.log
     
    7677                                        #por ultimo entubamos la salida al zenity progress para que nos muestre el resultado en pantalla
    7778                                done | zenity --progress  --auto-close --pulsate --width 500 --title="Zero-Center-Installer" --no-cancel > /dev/null 2>&1
    78                                
    79                         echo "Zero-center-------Your package $NAME_PACK has been INSTALLED in your system"
    80                         echo " " >> /tmp/zero-installer.log
    81                         echo "Zero-center-------Your package $NAME_PACK has been INSTALLED in your system" >> /tmp/zero-installer.log
    82                         echo "________________________________________________________________________________" >> /tmp/zero-installer.log
    83                         echo " " >> /tmp/zero-installer.log
    84                         su -c "notify-send -t 2000 -u normal -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$NAME_PACK $MSG_FINISH_INSTALLED /tmp/zero-installer.log'" $USER
    85                        
    86                         exit 0
     79                        echo "................................................................................." >> /tmp/zero-installer.log
     80                        if [ $TEST -eq 0 ]
     81                        then
     82                                echo "Zero-center-------Your package $NAME_PACK has been INSTALLED in your system"
     83                                echo " " >> /tmp/zero-installer.log
     84                                echo "Zero-center-------Your package $NAME_PACK has been INSTALLED in your system" >> /tmp/zero-installer.log
     85                                echo "________________________________________________________________________________" >> /tmp/zero-installer.log
     86                                echo " " >> /tmp/zero-installer.log
     87                                su -c "notify-send -t 2000 -u normal -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$NAME_PACK $MSG_FINISH_INSTALLED /tmp/zero-installer.log'" $USER
     88                                exit 0
     89                        else
     90                                echo "Zero-center-------Your package $NAME_PACK has NOT been INSTALLED in your system"
     91                                echo " " >> /tmp/zero-installer.log
     92                                echo "Zero-center-------Your package $NAME_PACK has NOT been INSTALLED in your system" >> /tmp/zero-installer.log
     93                                echo "________________________________________________________________________________" >> /tmp/zero-installer.log
     94                                echo " " >> /tmp/zero-installer.log
     95                                su -c "notify-send -t 2000 -u normal -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$NAME_PACK $MSG_FINISH_UNINSTALLED /tmp/zero-installer.log'" $USER
     96                                exit 1
     97                        fi
    8798               
    8899                else
     
    97108                       
    98109                        #En segundo plano realizaremos la instalacion del paquete almacenando su salida en nuestro log, eliminando nuestro fichero ayuda para salir del bucle.
    99                         (apt-get $INSTRUCCION -y --allow-unauthenticated $2 >> /tmp/zero-installer.log ; rm /tmp/zero-install.log) &
     110                        TEST=`(apt-get $INSTRUCCION -y --allow-unauthenticated $2 >> /tmp/zero-installer.log ; echo $?;rm /tmp/zero-install.log) &`
    100111                        echo "................................................................................." >> /tmp/zero-installer.log
    101112                        echo " " >> /tmp/zero-installer.log
     
    113124                                        #por ultimo entubamos la salida al zenity progress para que nos muestre el resultado en pantalla
    114125                                done | zenity --progress  --auto-close --pulsate --width 500 --title="Zero-Center-Installer" --no-cancel > /dev/null 2>&1
    115                        
    116                         echo "Zero-center-------Your package $2 has been $FINISHED in your system"
    117                         echo " " >> /tmp/zero-installer.log
    118                         echo "Zero-center-------Your package $2 has been $FINISHED in your system" >> /tmp/zero-installer.log
    119                         echo "________________________________________________________________________________" >> /tmp/zero-installer.log
    120                         echo " " >> /tmp/zero-installer.log
    121                         su -c "notify-send -t 2000 -u normal -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$2 $MSG_FINISH_SYSTEM1 $FINISHED $MSG_FINISH_SYSTEM /tmp/zero-installer.log'" $USER
     126                        if [ $TEST -eq 0 ]
     127                        then                   
     128                                echo "Zero-center-------Your package $2 has been $FINISHED in your system"
     129                                echo " " >> /tmp/zero-installer.log
     130                                echo "Zero-center-------Your package $2 has been $FINISHED in your system" >> /tmp/zero-installer.log
     131                                echo "________________________________________________________________________________" >> /tmp/zero-installer.log
     132                                echo " " >> /tmp/zero-installer.log
     133                                su -c "notify-send -t 2000 -u normal -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$2 $MSG_FINISH_SYSTEM1 $FINISHED $MSG_FINISH_SYSTEM /tmp/zero-installer.log'" $USER
     134                        else
     135                                echo "Zero-center-------Your package $2 has NOT been $FINISHED in your system"
     136                                echo " " >> /tmp/zero-installer.log
     137                                echo "Zero-center-------Your package $2 has NOT been $FINISHED in your system" >> /tmp/zero-installer.log
     138                                echo "________________________________________________________________________________" >> /tmp/zero-installer.log
     139                                echo " " >> /tmp/zero-installer.log
     140                                su -c "notify-send -t 2000 -u normal -i /usr/share/icons/lliurex-neu/scalable/apps/zero-center.svg 'Zero-Installer' '$2 $MSG_FINISH_ERROR $FINISHED $MSG_FINISH_SYSTEM /tmp/zero-installer.log'" $USER
     141                                exit 1
     142                        fi
    122143                fi
    123144                }
Note: See TracChangeset for help on using the changeset viewer.