Changeset 1858


Ignore:
Timestamp:
Jun 7, 2016, 11:58:29 AM (3 years ago)
Author:
daduve
Message:

Changing script for accv

Location:
zero-lliurex-dni/trunk/fuentes
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • zero-lliurex-dni/trunk/fuentes/zero-lliurex-dni.zlaunchers/zero-lliurex-accv.zmd

    r1833 r1858  
    1212TH_PROFILE_PATH="" # Absolute path to user firefox profile
    1313LIBRARY="secmod.db"
    14 ROUTE_LIBRARY="/var/lib/nssdb/"
     14ROUTE_LIBRARY="/var/lib/nssdb"
    1515ROUTE_MOZILLA="/usr/lib/firefox/browser/defaults/profile/"
     16ROUTE_THUNDERBIRD="/usr/lib/thunderbird/defaults/profile/"
     17ACCV_FILES="/usr/share/accv-files"
    1618ERROR=0
     19ACCV_LOG="/tmp/accv.log"
     20ACCV_ERROR="/tmp/.accv_error.log"
    1721
    1822export TEXTDOMAIN="zero-lliurex-accv"
     
    4852   
    4953   USER_HOME=$(getent passwd "$USER_NAME" | cut -d: -f 6)
    50 }
    51 
    52 test_libaetpkss(){
    53 
    54    if [ ! -e $LIBRARY ]; then
    55       zenity --info --text="$MSG_LIBRARY_NOT_FOUND $LIBRARY"
    56       ERROR=1
    57         echo "$ERROR" > /tmp/zero-lliurex-accv.tmp
    58       exit 1
    59    fi
     54   echo "My USER_HOME is: $USER_HOME" >> $ACCV_LOG
    6055}
    6156
     
    8681test_installed_package(){
    8782
    88    dpkg -s $1
    89    iRESULT=$?
    90    if [ $iRESULT -eq 1 ]; then
    91         return 0
    92    else
    93         ERROR=1
    94         echo "$ERROR" > /tmp/zero-lliurex-accv.tmp
    95         return 1
    96    fi
    97 }
     83   TEST=$( dpkg-query -s $1 2> /dev/null| grep Status | cut -d " " -f 4 )
     84        if [ "$TEST" == 'installed' ]; then
     85                ERROR=0
     86                echo "$ERROR $1 is installed in your system" > $ACCV_ERROR
     87                return 0
     88        else
     89                ERROR=1
     90                echo "$ERROR test_installed_package" > $ACCV_ERROR
     91                return 1       
     92        fi
     93}
     94
     95
    9896
    9997## Firefox functions
     
    127125      FF_PROFILE_PATH=$FF_PATH/$TMP_PATH
    128126   fi
     127   echo "My Firefox Profile is $FF_PROFILE_PATH" >> $ACCV_LOG
    129128   rm -f $TMP_FILE
    130129}
     130
     131
    131132
    132133## Thunderbird functions
     
    160161      TH_PROFILE_PATH=$TH_PATH/$TMP_PATH
    161162   fi
     163   echo "My Thunderbird Profile is $TH_PROFILE_PATH" >> $ACCV_LOG
    162164   rm -f $TMP_FILE
    163165}
     
    169171        if [ ! -d $FF_PROFILE_PATH ]; then
    170172                zenity --info --text="$MSG_SOME_PROBLEM_FIREFOX"
    171                 return 0
     173                return 1
    172174        fi
    173         ERROR=1
    174         echo "$ERROR" > /tmp/zero-lliurex-accv.tmp
    175         return 1
     175        ERROR=0
     176        echo "$ERROR firefox_user_profile" > $ACCV_ERROR
     177        return 0
    176178   else
    177179      zenity --info --text="$MSG_CREATING_FIREFOX"
     180      echo "$MSG_CREATING_FIREFOX" >> $ACCV_LOG
    178181        su $USER -c "firefox"
    179182        test_running_firefox
    180183        get_firefox_default_profile
     184        return 0
    181185   fi
    182186       
     
    189193        if [ ! -d $TH_PROFILE_PATH ]; then
    190194                zenity --info --text="$MSG_SOME_PROBLEM_THUNDER"
    191                 return 0
     195                return 1
    192196        fi
    193         ERROR=1
    194         echo "$ERROR" > /tmp/zero-lliurex-accv.tmp
    195         return 1
     197        ERROR=0
     198        echo "$ERROR thunderbird user profile" > $ACCV_ERROR
     199        return 0
    196200   else
    197201        zenity --info --text="$MSG_CREATING_THUNDER"
     202        echo "$MSG_CREATING_THUNDER" >> $ACCV_LOG
    198203        su $USER -c "thunderbird"
    199204        test_running_thunderbird
    200205        get_thunderbird_default_profile
    201    fi
    202        
    203 }
    204 
    205 test_firefox_accv_module(){
    206 
    207    if [ -z $FF_MODULE_EXISTS ]; then
    208         return 1
    209    fi
    210    return 0
    211 }
     206        return 0
     207   fi
     208       
     209}
     210
    212211
    213212remove_accv_module_firefox(){
     
    215214   #su $USER -c "modutil -disable $FF_MODULE_NAME -force -dbdir $FF_PROFILE_PATH 2>&1"
    216215   #su $USER -c "modutil -delete $FF_MODULE_NAME -force -dbdir $FF_PROFILE_PATH 2>&1"
    217    cd $USER_HOME/.mozilla/firefox/
    218         if [ -f $FF_PROFILE_PATH/secmod.db ]; then
    219                 su - $USER -c "rm $USER_HOME/.mozilla/firefox/$PROFPATH/secmod.db" >> debug.log
    220                 echo "Deleting obsolete library in firefox home"
     216        if [ -f $FF_PROFILE_PATH/$LIBRARY ]; then
     217                rm $FF_PROFILE_PATH/$LIBRARY>> $ACCV_LOG
     218                echo "Deleting obsolete library in firefox home $FF_PROFILE_PATH/secmod.db" >> $ACCV_LOG
    221219        fi
    222220}
     
    224222remove_accv_module_thunderbird(){
    225223
    226    su $USER -c "modutil -disable $TH_MODULE_NAME -force -dbdir $TH_PROFILE_PATH 2>&1"
    227    su $USER -c "modutil -delete $TH_MODULE_NAME -force -dbdir $TH_PROFILE_PATH 2>&1"
     224        if [ -f $TH_PROFILE_PATH/$LIBRARY ]; then
     225                rm $TH_PROFILE_PATH/$LIBRARY>> $ACCV_LOG
     226                echo "Deleting obsolete library in thunderbird home $TH_PROFILE_PATH/secmod.db" >> $ACCV_LOG
     227        fi
    228228}
    229229
     
    232232   #su $USER -c "modutil -add $FF_MODULE_NAME -force -libfile $LIBRARY -dbdir $FF_PROFILE_PATH 2>&1"
    233233   #su $USER -c "modutil -enable $FF_MODULE_NAME -force -dbdir $FF_PROFILE_PATH 2>&1"
    234         cd $USER_HOME/.mozilla/firefox/
    235         su - $USER -c "cp $USER_HOME/secmod.db $FF_PROFILE_PATH" >> debug.log
    236         echo "Creating link to firefox home."
     234        su $USER -c "ln -s $ROUTE_LIBRARY/$LIBRARY $FF_PROFILE_PATH" >> $ACCV_LOG
     235        echo "Creating link to firefox home, from $ROUTE_LIBRARY/$LIBRARY to $FF_PROFILE_PATH/secmod.db" >> $ACCV_LOG
     236               
    237237}
    238238
    239239enable_accv_module_thunderbird(){
    240240
    241    su $USER -c "modutil -add $TH_MODULE_NAME -force -libfile $LIBRARY -dbdir $TH_PROFILE_PATH 2>&1"
    242    su $USER -c "modutil -enable $TH_MODULE_NAME -force -dbdir $TH_PROFILE_PATH 2>&1"
     241        su $USER -c "ln -s $ROUTE_LIBRARY/$LIBRARY $TH_PROFILE_PATH" >> $ACCV_LOG
     242        echo "Creating link to thunderbird home, from $ROUTE_LIBRARY/$LIBRARY to $TH_PROFILE_PATH/secmod.db" >> $ACCV_LOG
    243243}
    244244
    245245do_firefox(){
    246246
    247    test_installed_package "firefox"
    248    if [ $? ]; then
     247   test_installed_package firefox
     248   #rgrep 0 $ACCV_ERROR
     249   TESTED=$?
     250   if [ "$TESTED" == "0" ] ; then
    249251        test_running_firefox
    250252        if [ $? -gt 0 ]; then
    251253                zenity --info --text="$MSG_RUNNING_FIREFOX"
    252254                ERROR=1
    253                 echo "$ERROR" >> /tmp/zero-lliurex-accv.tmp
     255                echo "$ERROR do_firefox" > $ACCV_ERROR
    254256                exit 2
    255257        else
    256258                test_firefox_user_profile
    257                 test_ff_up=$?
    258                 echo "--->"$test_ff_up"<---"
    259                 if [ $? ]; then
     259                if [ $? == 0 ]; then
     260                        echo "---> PERFIL DE FIREFOX CONOCIDO CONTINUAMOS <---" >> $ACCV_LOG
    260261                        remove_accv_module_firefox
    261262                        enable_accv_module_firefox
     
    265266      zenity --info --text="$MSG_NOT_FIREFOX"
    266267      ERROR=1
    267         echo "$ERROR" > /tmp/zero-lliurex-accv.tmp
     268        echo "$ERROR do_firefox_else" > $ACCV_ERROR
     269        echo "*** $MSG_NOT_FIREFOX ***" >> $ACCV_LOG
    268270      exit 1
    269271   fi
     
    272274do_thunderbird(){
    273275
    274    test_installed_package "thunderbird"
    275    if [ $? ]; then
     276   test_installed_package thunderbird
     277   TESTED=$?
     278   if [ "$TESTED" == "0" ] ; then
    276279        test_running_thunderbird
    277280        if [ $? -gt 0 ]; then
    278281                zenity --info --text="$MSG_RUNNING_THUNDER"
    279282                 ERROR=1
    280                 echo "$ERROR" > /tmp/zero-lliurex-accv.tmp
     283                echo "$ERROR do_thunderbird" > $ACCV_ERROR
    281284                exit 2
    282285        else
    283286                test_thunderbird_user_profile
    284                 test_th_up=$?
    285                 echo "--->"$test_th_up"<---"
    286                 if [ $? ]; then
     287                if [ $? == 0 ]; then
     288                        echo "---> PERFIL DE THUNDERBIRD CONOCIDO CONTINUAMOS <---" >> $ACCV_LOG
    287289                        remove_accv_module_thunderbird
    288290                        enable_accv_module_thunderbird
     
    292294      zenity --info --text="$MSG_NOT_THUNDER"
    293295      ERROR=1
    294       echo "$ERROR" > /tmp/zero-lliurex-accv.tmp
     296      echo "$ERROR do_thunderbird_else" > $ACCV_ERROR
     297      echo "*** $MSG_NOT_THUNDER ***" >> $ACCV_LOG
    295298      exit 1
    296299   fi
     
    299302
    300303make_link(){
     304
     305        #Preparo el sistema con la libreria original renombrada
     306        if [ -f  "$ROUTE_LIBRARY/secmod_orig.db" ]; then
     307                cp $ACCV_FILES/secmod.db /var/lib/nssdb/secmod.db
     308                echo "$ROUTE_LIBRARY/secmod_orig.db exists in your system only make the COPY again." >> $ACCV_LOG
     309        else
     310                mv $ROUTE_LIBRARY/$LIBRARY $ROUTE_LIBRARY/secmod_orig.db
     311                cp $ACCV_FILES/$LIBRARY $ROUTE_LIBRARY/$LIBRARY
     312                echo "$ROUTE_LIBRARY/secmod_orig.db don't exists in your system, make MOVE and COPY." >> $ACCV_LOG
     313        fi
     314               
    301315       
    302316        # Compruebo si existe la libreria que necesito.
    303317        if [ ! -e $ROUTE_MOZILLA$LIBRARY ]; then
    304                 echo "Library don't exists in firefox default"
     318                echo "Library for firefox don't exists in firefox default">> $ACCV_LOG
    305319               
    306320                #No existe la libreria compruebo que el directorio donde he de crear el enlace existe, sino lo creo.
    307321                if [ ! -d $ROUTE_MOZILLA ]; then
    308                         echo "Create directory for ln"
     322                        echo "Create directory in firefox for ln">> $ACCV_LOG
    309323                        mkdir -p  $ROUTE_MOZILLA
    310324                fi
    311325               
    312326                #Compruebo que existe la libreria de origen.
    313                 if [ -e $ROUTE_LIBRARY$LIBRARY ]; then
    314                 echo "Make the ln from original file to mozilla directory"
    315                         ln -s $ROUTE_LIBRARY$LIBRARY $ROUTE_MOZILLA$LIBRARY || echo " Link is not done: $ROUTE_MOZILLA$LIBRARY "
     327                if [ -e $ROUTE_LIBRARY/$LIBRARY ]; then
     328                echo "Make the ln from original file to mozilla firefox directory">> $ACCV_LOG
     329                        ln -s $ROUTE_LIBRARY/$LIBRARY $ROUTE_MOZILLA$LIBRARY || echo " Link is not done: $ROUTE_MOZILLA$LIBRARY " >> $ACCV_LOG
    316330       
    317331                else
    318                         echo " * Warning :  $ROUTE_LIBRARY$LIBRARY      not found in your system."
    319                         echo ""
    320                         echo "Abort installation"
    321                         zenity --error --text="Impossible to create ln with $ROUTE_LIBRARY$LIBRARY because is not in your system. $MSG_FINAL_ACCV_ERROR"
     332                        echo " * Warning :  $ROUTE_LIBRARY/$LIBRARY     not found in your system.">> $ACCV_LOG
     333                        echo "">> $ACCV_LOG
     334                        echo "Abort installation">> $ACCV_LOG
     335                        zenity --error --text="Impossible to create ln with $ROUTE_LIBRARY/$LIBRARY because is not in your system. $MSG_FINAL_ACCV_ERROR"
    322336                        exit 1
    323337                fi
    324         fi
     338        else
     339                echo "Mozilla FIREFOX default preseed has the link" >> $ACCV_LOG
     340        fi
     341        echo "Link for library has created in $ROUTE_MOZILLA$LIBRARY" >> $ACCV_LOG
     342       
     343        # Compruebo si existe la libreria que necesito.
     344        if [ ! -e $ROUTE_THUNDERBIRD$LIBRARY ]; then
     345                echo "Library don't exists in thunderbird default">> $ACCV_LOG
     346               
     347                #No existe la libreria compruebo que el directorio donde he de crear el enlace existe, sino lo creo.
     348                if [ ! -d $ROUTE_THUNDERBIRD ]; then
     349                        echo "Create thunderbird directory for ln">> $ACCV_LOG
     350                        mkdir -p  $ROUTE_THUNDERBIRD
     351                fi
     352               
     353                #Compruebo que existe la libreria de origen.
     354                if [ -e $ROUTE_LIBRARY/$LIBRARY ]; then
     355                echo "Make the ln from original file to thunderbird directory">> $ACCV_LOG
     356                        ln -s $ROUTE_LIBRARY/$LIBRARY $ROUTE_THUNDERBIRD$LIBRARY || echo " Link is not done: $ROUTE_THUNDERBIRD$LIBRARY " >> $ACCV_LOG
     357       
     358                else
     359                        echo " * Warning :  $ROUTE_LIBRARY/$LIBRARY     not found in your system.">> $ACCV_LOG
     360                        echo "">> $ACCV_LOG
     361                        echo "Abort installation">> $ACCV_LOG
     362                        zenity --error --text="Impossible to create ln with $ROUTE_LIBRARY/$LIBRARY because is not in your system. $MSG_FINAL_ACCV_ERROR"
     363                        exit 1
     364                fi
     365        else
     366                echo "Mozilla THUNDERBIRD default preseed has the link" >> $ACCV_LOG
     367        fi
     368        echo "Link for THUNDERBIRD library has created in $ROUTE_MOZILLA$LIBRARY" >> $ACC
     369       
    325370
    326371}
     
    332377                zenity --error --text="Impossible to install $2, problems with repos. $MSG_FINAL_ACCV_ERROR"
    333378                ERROR=1
    334                 echo "$ERROR" >> accv_debug.log
     379                echo "$ERROR check_install" > $ACCV_ERROR
    335380                exit 1
    336381        fi
     
    342387
    343388#####################################################
    344 echo "Start smartcard installation at "`date` > accv_debug.log
     389echo "#####################################################" >> $ACCV_LOG
     390echo "Start smartcard installation at "`date` > $ACCV_LOG
     391echo "#####################################################" >> $ACCV_LOG
     392echo " " >> $ACCV_LOG
     393ERROR=0
     394echo "$ERROR inicializacion" > $ACCV_ERROR
    345395USER_HOME=$(pwd)
    346396USER=$(who | awk '{print $1;}')
    347397
     398touch /tmp/kk.txt
    348399#instalo paquetes necesarios de los repositorios segun la arquitectura.
    349400
     
    351402       
    352403        #echo "Es 64 bits"
    353         zero-installer install libccid
    354         check_install $? "libccid"
    355         zero-installer install pcscd
    356         check_install $? "pcscd"
    357         zero-installer install libpcsclite1
    358         check_install $? "libpcsclite1"
    359         zero-installer install libwxbase2.8-0
    360         check_install $? "libwxbase2.8-0"
    361         zero-installer install libwxgtk2.8-0
    362         check_install $? "libwxgtk2.8-0"
    363         zero-installer install safesignidentityclient
    364         check_install $? "safesignidentityclient"
     404        zero-installer install libccid >> $ACCV_LOG
     405        check_install $? "libccid" >> $ACCV_LOG
     406        zero-installer install pcscd >> $ACCV_LOG
     407        check_install $? "pcscd" >> $ACCV_LOG
     408        zero-installer install libpcsclite1 >> $ACCV_LOG
     409        check_install $? "libpcsclite1" >> $ACCV_LOG
     410        zero-installer install libwxbase2.8-0 >> $ACCV_LOG
     411        check_install $? "libwxbase2.8-0" >> $ACCV_LOG
     412        zero-installer install libwxgtk2.8-0 >> $ACCV_LOG
     413        check_install $? "libwxgtk2.8-0" >> $ACCV_LOG
     414        zero-installer install safesignidentityclient >> $ACCV_LOG
     415        check_install $? "safesignidentityclient" >> $ACCV_LOG
    365416
    366417else
    367418
    368419        #echo "Es 32 bits"
    369         zero-installer install libccid
    370         check_install $? "libccid"
    371         zero-installer install pcscd
    372         check_install $? "pcscd"
    373         zero-installer install libpcsclite1
    374         check_install $? "libpcsclite1"
    375         zero-installer install libtiff4_3.9.6-11_i386.deb
    376         check_install $? "libtiff4_3.9.6-11_i386.deb"
    377         zero-installer install libwxbase2.8-0_2.8.12.1-12_i386.deb
    378         check_install $? "libwxbase2.8-0_2.8.12.1-12_i386.deb"
    379         zero-installer install libwxgtk2.8-0_2.8.12.1-12_i386.deb
    380         check_install $? "libwxgtk2.8-0_2.8.12.1-12_i386.deb"
    381         zero-installer install SafeSignIC3.0.112-i386-ub1204-tu-admin.deb
    382         check_install $? "SafeSignIC3.0.112-i386-ub1204-tu-admin.deb"
     420        zero-installer install libccid >> $ACCV_LOG
     421        check_install $? "libccid" >> $ACCV_LOG
     422        zero-installer install pcscd >> $ACCV_LOG
     423        check_install $? "pcscd" >> $ACCV_LOG
     424        zero-installer install libpcsclite1 >> $ACCV_LOG
     425        check_install $? "libpcsclite1" >> $ACCV_LOG
     426        zero-installer install libtiff4_3.9.6 >> $ACCV_LOG
     427        check_install $? "libtiff4_3.9.6" >> $ACCV_LOG
     428        zero-installer install libwxbase2.8 >> $ACCV_LOG
     429        check_install $? "libwxbase2.8" >> $ACCV_LOG
     430        zero-installer install libwxgtk2.8 >> $ACCV_LOG
     431        check_install $? "libwxgtk2.8-0" >> $ACCV_LOG
     432        zero-installer install safesignidentityclient >> $ACCV_LOG
     433        check_install $? "safesignidentityclient" >> $ACCV_LOG
    383434
    384435
     
    386437
    387438# Si falla la instalacion de algun paquete se habrá abortado la instalación
    388 
    389 #Configuració SafeSign
    390 su - $USER -c "mkdir ~/.safesign" >> accv_debug.log
    391 su - $USER -c "cp /usr/share/accv-files/registry ~/.safesign" >>  accv_debug.log
    392 
    393439(
    394440## Get user home folder
    395441#######################
    396442user_home
    397 
    398 #
     443#echo "$USER_HOME"
     444#Configuració SafeSign
     445[ -d $USER_HOME/.safesign ] || su - $USER -c "mkdir ~/.safesign" >> $ACCV_LOG
     446su - $USER -c "cp $ACCV_FILES/registry ~/.safesign" >>  $ACCV_LOG
     447
    399448# Make link
    400449make_link
     450#
    401451echo "# $MSG_ZENITY_ACCV_FIREFOX_1" ; sleep 1
    402452echo "20"
     
    405455echo "# $MSG_ZENITY_ACCV_FIREFOX_2"; FF_PATH="$USER_HOME/.mozilla/firefox"
    406456do_firefox
    407 exit 0
    408457echo "60"
     458if [ $(rgrep 1 $ACCV_ERROR) ] ; then 
     459        zenity --error --text="$MSG_FINAL_ERROR" 
     460        exit 1
     461fi
    409462echo "# $MSG_ZENITY_ACCV_THUNDER_1";TH_MODULE_NAME="ACCV_GYD_PKCS_11"
    410463echo "80"
     
    414467) |
    415468zenity --progress \
    416   --title="ZERO-LLIUREX-ACCV" \
     469 --title="ZERO-LLIUREX-ACCV" \
    417470  --text="$MSG_INSTALLING_ACCV_PROGRESS" \
    418471  --percentage=0 \
     
    422475 
    423476#capturo el error a ver si todo fue bien o fallo algo
    424 ERROR=$(cat /tmp/zero-lliurex-dni.tmp)
    425 
    426 if [ '$ERROR' != '0' ] ; then 
    427         zenity --error --text="$MSG_FINAL_ERROR" 
     477ERROR=$(cat $ACCV_ERROR)
     478
     479if [ $(rgrep 1 $ACCV_ERROR) ] ; then 
     480        zenity --error --text="$MSG_FINAL_ERROR"
     481        echo "" >> $ACCV_LOG
     482        echo "$MSG_FINAL_ERROR" >> $ACCV_LOG
    428483        exit 1
    429484  else
    430485        zenity --info --text="$MSG_FINAL_ACCV_OK"
     486        echo "" >> $ACCV_LOG
     487        echo "$MSG_FINAL_ACCV_OK" >> $ACCV_LOG
    431488fi
    432489
Note: See TracChangeset for help on using the changeset viewer.