[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-clonage/sources/scripts/ -> se3_get_install_client_linux.sh (source)

   1  #!/bin/bash
   2  
   3  # $Id: se3_get_install_client_linux.sh 8171 2014-05-31 09:49:24Z crob $
   4  # Auteur: Stephane Boireau
   5  # Derniere modification: 29/05/2014
   6  
   7  # - telecharger le dispositif Client Linux depuis http://wawadeb.crdp.ac-caen.fr/iso/client_linux/
   8  
   9  . /usr/share/se3/includes/config.inc.sh -d
  10  . /usr/share/se3/includes/functions.inc.sh
  11  
  12  COLTITRE="\033[1;35m"   # Rose
  13  COLPARTIE="\033[1;34m"  # Bleu
  14  
  15  COLTXT="\033[0;37m"     # Gris
  16  COLCHOIX="\033[1;33m"   # Jaune
  17  COLDEFAUT="\033[0;33m"  # Brun-jaune
  18  COLSAISIE="\033[1;32m"  # Vert
  19  
  20  COLCMD="\033[1;37m"     # Blanc
  21  
  22  COLERREUR="\033[1;31m"  # Rouge
  23  COLINFO="\033[0;36m"    # Cyan
  24  
  25  # Parametres
  26  timestamp=$(date +%s)
  27  timedate=$(date "+%Y%m%d_%H%M%S")
  28  
  29  src="http://wawadeb.crdp.ac-caen.fr/iso/client_linux"
  30  
  31  tmp="/var/se3/tmp_client_linux_$timedate}"
  32  mkdir -p "$tmp"
  33  chmod 700 $tmp
  34  
  35  # ========================================
  36  
  37  # Valeurs des versions en place recuperees de se3db.params:
  38  version_pxe_client_linux_en_place="$pxe_client_linux_version"
  39  
  40  # ========================================
  41  
  42  dossier_ressource_dispositif_pxe_client_linux=/tftpboot/client_linux
  43  mkdir -p $dossier_ressource_dispositif_pxe_client_linux}
  44  
  45  t=$(echo "$*" | grep "check_version")
  46  if [ -n "$t" ]; then
  47      cd $tmp
  48      wget $src/versions.txt > /dev/null 2>&1
  49      if [ "$?" = 0 -a -e versions.txt ]; then
  50          VarchPxeClientLin_en_ligne=$(grep ";install_client_linux_archive-tftp.tar.gz$" $tmp/versions.txt | cut -d";" -f1)
  51  
  52          # Pour le premier lancement: mise en place du nouveau dispositif
  53          if [ -z "$VarchPxeClientLin_en_place" ]; then
  54              md5_en_ligne=$(grep ";install_client_linux_archive-tftp.tar.gz$" $tmp/versions.txt | cut -d";" -f2)
  55              if [ -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz" ]; then
  56                  md5_en_place=$(md5sum $dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz|cut -d" " -f1)
  57                  if [ "$md5_en_place" = "$md5_en_ligne" ]; then
  58                      VarchPxeClientLin=$VarchPxeClientLin_en_ligne
  59                      SETMYSQL VarchPxeClientLin "$VarchPxeClientLin" "version actuelle archive du dispositif installation PXE client Linux" 7
  60                      VarchPxeClientLin_en_place=$VarchPxeClientLin_en_ligne
  61                  fi
  62              fi
  63          fi
  64  
  65          VscriptPxeClientLin_en_ligne=$(grep ";install_client_linux_mise_en_place.sh$" $tmp/versions.txt | cut -d";" -f1)
  66  
  67          if [ -z "$VscriptPxeClientLin_en_place" ]; then
  68              md5_en_ligne=$(grep ";install_client_linux_mise_en_place.sh$" $tmp/versions.txt | cut -d";" -f2)
  69              if [ -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_mise_en_place.sh" ]; then
  70                  md5_en_place=$(md5sum $dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_mise_en_place.sh|cut -d" " -f1)
  71                  if [ "$md5_en_place" = "$md5_en_ligne" ]; then
  72                      VscriptPxeClientLin=$VscriptPxeClientLin_en_ligne
  73                      SETMYSQL VscriptPxeClientLin "$VscriptPxeClientLin" "version actuelle script de mise en place du dispositif installation PXE client Linux" 7
  74                      VscriptPxeClientLin_en_place=$VscriptPxeClientLin_en_ligne
  75                  fi
  76              fi
  77          fi
  78  
  79          temoin_erreur="n"
  80          temoin_fichier_manquant="n"
  81          if [ ! -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz" ]; then
  82              temoin_fichier_manquant="y"
  83              VarchPxeClientLin_en_place="<span style='color:red'>Absent</span>"
  84          else
  85              md5_en_place=$(md5sum $dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz|cut -d" " -f1)
  86              md5_en_ligne=$(grep ";install_client_linux_archive-tftp.tar.gz$" $tmp/versions.txt | cut -d";" -f2)
  87      
  88              if [ "$md5_en_ligne" != "$md5_en_place" ]; then
  89                  VarchPxeClientLin_en_place="<span style='color:red'>Somme MD5 incorrecte</span>"
  90                  temoin_erreur="y"
  91              fi
  92          fi
  93  
  94          if [ ! -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_mise_en_place.sh" ]; then
  95              temoin_fichier_manquant="y"
  96              VscriptPxeClientLin_en_place="<span style='color:red'>Absent</span>"
  97          else
  98              md5_en_place=$(md5sum $dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz|cut -d" " -f1)
  99              md5_en_ligne=$(grep ";install_client_linux_archive-tftp.tar.gz$" $tmp/versions.txt | cut -d";" -f2)
 100      
 101              if [ "$md5_en_ligne" != "$md5_en_place" ]; then
 102                  VscriptPxeClientLin_en_place="<span style='color:red'>Somme MD5 incorrecte</span>"
 103                  temoin_erreur="y"
 104              fi
 105          fi
 106  
 107          if [ "$temoin_erreur" != "y" -a "$temoin_fichier_manquant" != "y" -a "$VarchPxeClientLin_en_ligne" = "$VarchPxeClientLin_en_place" -a "$VscriptPxeClientLin_en_ligne" = "$VscriptPxeClientLin_en_place" ]; then
 108              echo "<p><span style='color:green'>Dispositif &agrave; jour</span></p>";
 109          else
 110              echo "<p><span style='color:red'>Mise &agrave; jour disponible</span></p>";
 111          fi
 112  
 113          echo "<table class='crob'>
 114  <tr>
 115      <th>&nbsp;</th>
 116      <th>Sur votre SE3</th>
 117      <th>En ligne</th>
 118  </tr>
 119  <tr>
 120      <th>Archive</th>
 121      <td>$VarchPxeClientLin_en_place</td>
 122      <td>$VarchPxeClientLin_en_ligne</td>
 123  </tr>
 124  <tr>
 125      <th>Script</th>
 126      <td>$VscriptPxeClientLin_en_place</td>
 127      <td>$VscriptPxeClientLin_en_ligne</td>
 128  </tr>
 129  </table>";
 130  
 131      else
 132          echo "<p><span style='color:red'>ECHEC du telechargement du fichier des versions.</span></p>"
 133      fi
 134  
 135      exit
 136  fi
 137  
 138  # ========================================
 139  
 140  t=$(echo "$*" | grep "mode=html")
 141  if [ -z "$t" ]; then
 142      mode="cmdline"
 143  else
 144      mode="html"
 145  fi
 146  
 147  if [ "$mode" = "cmdline" ]; then
 148      echo -e "$COLTXT"
 149  else
 150      echo "<pre>"
 151      echo "<h3>"
 152  fi
 153  echo "Mise en place des fichiers utiles pour l'installation de client Linux en boot PXE."
 154  if [ "$mode" = "cmdline" ]; then
 155      echo -e "$COLCMD"
 156  else
 157      echo "</h3>"
 158  fi
 159  
 160  # Telecharger
 161  cd $tmp
 162  wget $src/versions.txt
 163  if [ "$?" != "0" ]; then
 164      if [ "$mode" = "cmdline" ]; then
 165          echo -e "$COLERREUR"
 166      else
 167          echo "<span style='color:red'>"
 168      fi
 169      echo "ERREUR lors du telechargement de $src/versions.txt"
 170      echo "ABANDON."
 171      if [ "$mode" = "cmdline" ]; then
 172          echo -e "$COLTXT"
 173      else
 174          echo "</span>"
 175          echo "</pre>"
 176      fi
 177      exit
 178  else
 179      if [ "$mode" = "cmdline" ]; then
 180          echo -e "$COLINFO"
 181      else
 182          echo "<span style='color:green'>"
 183      fi
 184      echo "SUCCES du telechargement de $src/versions.txt"
 185      if [ "$mode" = "cmdline" ]; then
 186          echo -e "$COLTXT"
 187      else
 188          echo "</span>"
 189      fi
 190  fi
 191  
 192  VarchPxeClientLin_en_ligne=$(grep ";install_client_linux_archive-tftp.tar.gz$" $tmp/versions.txt | cut -d";" -f1)
 193  VscriptPxeClientLin_en_ligne=$(grep ";install_client_linux_mise_en_place.sh$" $tmp/versions.txt | cut -d";" -f1)
 194  
 195  t=$(echo "$*" | grep "suppr_dispositif_precedent")
 196  if [ -n "$t" ]; then
 197      if [ "$mode" = "cmdline" ]; then
 198          echo -e "$COLINFO"
 199      else
 200          echo "<span style='color:green'>"
 201      fi
 202  
 203      echo "Menage prealable au telechargement..."
 204  
 205      fich_tmp=$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz
 206      if [ -e "$fich_tmp}" ]; then
 207          echo "Suppression de $fich_tmp}"
 208          rm -f $fich_tmp}
 209      else
 210          echo "Pas de $fich_tmp} present."
 211      fi
 212  
 213      fich_tmp=$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_mise_en_place.sh
 214      if [ -e "$fich_tmp}" ]; then
 215          echo "Suppression de $fich_tmp}"
 216          rm -f $fich_tmp}
 217      else
 218          echo "Pas de $fich_tmp} present."
 219      fi
 220  
 221      if [ "$mode" = "cmdline" ]; then
 222          echo -e "$COLTXT"
 223      else
 224          echo "</span>"
 225      fi
 226  fi
 227  
 228  # On controle si des fichiers install PXE client Linux sont deja en place
 229  if [ -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz" -a -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_mise_en_place.sh" ]; then
 230  
 231      if [ -z "$VarchPxeClientLin_en_place" ]; then
 232          md5_en_ligne=$(grep ";install_client_linux_archive-tftp.tar.gz$" $tmp/versions.txt | cut -d";" -f2)
 233          if [ -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz" ]; then
 234              md5_en_place=$(md5sum $dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz|cut -d" " -f1)
 235              if [ "$md5_en_place" = "$md5_en_ligne" ]; then
 236                  VarchPxeClientLin=$VarchPxeClientLin_en_ligne
 237                  SETMYSQL VarchPxeClientLin "$VarchPxeClientLin" "version actuelle archive du dispositif installation PXE client Linux" 7
 238                  VarchPxeClientLin_en_place=$VarchPxeClientLin_en_ligne
 239              fi
 240          fi
 241      fi
 242  
 243      VscriptPxeClientLin_en_ligne=$(grep ";install_client_linux_mise_en_place.sh$" $tmp/versions.txt | cut -d";" -f1)
 244  
 245      if [ -z "$VscriptPxeClientLin_en_place" ]; then
 246          md5_en_ligne=$(grep ";install_client_linux_mise_en_place.sh$" $tmp/versions.txt | cut -d";" -f2)
 247          if [ -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_mise_en_place.sh" ]; then
 248              md5_en_place=$(md5sum $dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_mise_en_place.sh|cut -d" " -f1)
 249              if [ "$md5_en_place" = "$md5_en_ligne" ]; then
 250                  VscriptPxeClientLin=$VscriptPxeClientLin_en_ligne
 251                  SETMYSQL VscriptPxeClientLin "$VscriptPxeClientLin" "version actuelle script de mise en place du dispositif installation PXE client Linux" 7
 252                  VscriptPxeClientLin_en_place=$VscriptPxeClientLin_en_ligne
 253              fi
 254          fi
 255      fi
 256  
 257      if [ -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz" ]; then
 258          md5_en_place=$(md5sum $dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz|cut -d" " -f1)
 259          md5_en_ligne=$(grep ";install_client_linux_archive-tftp.tar.gz$" $tmp/versions.txt | cut -d";" -f2)
 260  
 261          if [ "$md5_en_ligne" != "$md5_en_place" ]; then
 262              VarchPxeClientLin_en_place=""
 263          fi
 264      fi
 265  
 266      if [ -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_mise_en_place.sh" ]; then
 267          md5_en_place=$(md5sum $dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz|cut -d" " -f1)
 268          md5_en_ligne=$(grep ";install_client_linux_archive-tftp.tar.gz$" $tmp/versions.txt | cut -d";" -f2)
 269  
 270          if [ "$md5_en_ligne" != "$md5_en_place" ]; then
 271              VscriptPxeClientLin_en_place=""
 272          fi
 273      fi
 274  
 275      # On controle la version des fichiers
 276      if [ "$VarchPxeClientLin_en_ligne" = "$VarchPxeClientLin_en_place" -a "$VscriptPxeClientLin_en_ligne" = "$VscriptPxeClientLin_en_place" ]; then
 277  
 278          if [ "$mode" = "cmdline" ]; then
 279              echo -e "$COLINFO"
 280          else
 281              echo "<span style='color:green'>"
 282          fi
 283          echo "Les fichiers archive et script sont deja les plus recents; On ne les re-telecharge pas."
 284          if [ "$mode" = "cmdline" ]; then
 285              echo -e "$COLTXT"
 286          else
 287              echo "</span>"
 288          fi
 289          temoin_telech_requis="n"
 290      else
 291          # La version a change.
 292          temoin_telech_requis="y"
 293      fi
 294  else
 295      # Il manque au moins un fichier, on telecharge pour mettre a jour
 296      temoin_telech_requis="y"
 297  fi
 298  
 299  if [ "$temoin_telech_requis" = "y" ]; then
 300  
 301      md5_en_place=""
 302      md5_en_ligne=""
 303      if [ -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz" ]; then
 304          md5_en_place=$(md5sum $dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz|cut -d" " -f1)
 305          md5_en_ligne=$(grep ";install_client_linux_archive-tftp.tar.gz$" $tmp/versions.txt | cut -d";" -f2)
 306      fi
 307  
 308      if [ ! -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_archive-tftp.tar.gz" -o "$md5_en_ligne" != "$md5_en_place" -o "$VarchPxeClientLin_en_ligne" != "$VarchPxeClientLin_en_place" ]; then
 309          wget $src/install_client_linux_archive-tftp.tar.gz
 310          if [ "$?" != "0" ]; then
 311              if [ "$mode" = "cmdline" ]; then
 312                  echo -e "$COLERREUR"
 313              else
 314                  echo "<span style='color:red'>"
 315              fi
 316              echo "ERREUR lors du telechargement de $src/install_client_linux_archive-tftp.tar.gz"
 317              echo "ABANDON."
 318              if [ "$mode" = "cmdline" ]; then
 319                  echo -e "$COLTXT"
 320              else
 321                  echo "</span>"
 322                  echo "</pre>"
 323              fi
 324              exit
 325          else
 326              if [ "$mode" = "cmdline" ]; then
 327                  echo -e "$COLINFO"
 328              else
 329                  echo "<span style='color:green'>"
 330              fi
 331              echo "SUCCES du telechargement de $src/install_client_linux_archive-tftp.tar.gz"
 332              if [ "$mode" = "cmdline" ]; then
 333                  echo -e "$COLTXT"
 334              else
 335                  echo "</span>"
 336              fi
 337      
 338              md5_telech=$(md5sum install_client_linux_archive-tftp.tar.gz|cut -d" " -f1)
 339              md5_en_ligne=$(grep ";install_client_linux_archive-tftp.tar.gz$" $tmp/versions.txt | cut -d";" -f2)
 340              if [ "$md5_telech" != "$md5_en_ligne" ]; then
 341                  if [ "$mode" = "cmdline" ]; then
 342                      echo -e "$COLERREUR"
 343                  else
 344                      echo "<span style='color:red'>"
 345                  fi
 346                  echo "ANOMALIE: La somme MD5 ne coincide pas: $md5_en_ligne en ligne et $md5_telech telecharge."
 347                  if [ "$mode" = "cmdline" ]; then
 348                      echo -e "$COLTXT"
 349                  else
 350                      echo "</span>"
 351                      echo "</pre>"
 352                  fi
 353                  exit
 354              fi
 355          fi
 356  
 357          liste_fichiers_a_copier="$liste_fichiers_a_copier install_client_linux_archive-tftp.tar.gz"
 358      fi
 359  
 360      md5_en_place=""
 361      md5_en_ligne=""
 362      if [ -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_mise_en_place.sh" ]; then
 363          md5_en_place=$(md5sum $dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_mise_en_place.sh|cut -d" " -f1)
 364          md5_en_ligne=$(grep ";install_client_linux_mise_en_place.sh$" $tmp/versions.txt | cut -d";" -f2)
 365      fi
 366  
 367      if [ ! -e "$dossier_ressource_dispositif_pxe_client_linux}/install_client_linux_mise_en_place.sh" -o "$md5_en_ligne" != "$md5_en_place" -o "$VscriptPxeClientLin_en_ligne" != "$VscriptPxeClientLin_en_place" ]; then
 368          wget $src/install_client_linux_mise_en_place.sh
 369          if [ "$?" != "0" ]; then
 370              if [ "$mode" = "cmdline" ]; then
 371                  echo -e "$COLERREUR"
 372              else
 373                  echo "<span style='color:red'>"
 374              fi
 375              echo "ERREUR lors du telechargement de $src/install_client_linux_mise_en_place.sh"
 376              echo "ABANDON."
 377              if [ "$mode" = "cmdline" ]; then
 378                  echo -e "$COLTXT"
 379              else
 380                  echo "</span>"
 381                  echo "</pre>"
 382              fi
 383              exit
 384          else
 385              if [ "$mode" = "cmdline" ]; then
 386                  echo -e "$COLINFO"
 387              else
 388                  echo "<span style='color:green'>"
 389              fi
 390              echo "SUCCES du telechargement de $src/install_client_linux_mise_en_place.sh"
 391              if [ "$mode" = "cmdline" ]; then
 392                  echo -e "$COLTXT"
 393              else
 394                  echo "</span>"
 395              fi
 396      
 397              md5_telech=$(md5sum install_client_linux_mise_en_place.sh|cut -d" " -f1)
 398              md5_en_ligne=$(grep ";install_client_linux_mise_en_place.sh$" $tmp/versions.txt | cut -d";" -f2)
 399              if [ "$md5_telech" != "$md5_en_ligne" ]; then
 400                  if [ "$mode" = "cmdline" ]; then
 401                      echo -e "$COLERREUR"
 402                  else
 403                      echo "<span style='color:red'>"
 404                  fi
 405                  echo "ANOMALIE: La somme MD5 ne coincide pas: $md5_en_ligne en ligne et $md5_telech telecharge."
 406                  if [ "$mode" = "cmdline" ]; then
 407                      echo -e "$COLTXT"
 408                  else
 409                      echo "</span>"
 410                      echo "</pre>"
 411                  fi
 412                  exit
 413              fi
 414          fi
 415  
 416          liste_fichiers_a_copier="$liste_fichiers_a_copier install_client_linux_mise_en_place.sh"
 417      fi
 418  
 419      if [ "$mode" = "cmdline" ]; then
 420          echo -e "$COLTXT"
 421      else
 422          echo "<b>"
 423      fi
 424      echo "Copie des fichiers vers leur emplacement..."
 425      if [ "$mode" = "cmdline" ]; then
 426          echo -e "$COLCMD"
 427      else
 428          echo "</b>"
 429      fi
 430      cp -fv $liste_fichiers_a_copier $dossier_ressource_dispositif_pxe_client_linux}/
 431  
 432      if [ "$?" != "0"  ]; then
 433          if [ "$mode" = "cmdline" ]; then
 434              echo -e "$COLERREUR"
 435          else
 436              echo "<span style='color:red'>"
 437          fi
 438  
 439          echo "ERREUR lors de la copie"
 440  
 441          if [ "$mode" = "cmdline" ]; then
 442              echo -e "$COLTXT"
 443          else
 444              echo "</span>"
 445              echo "</pre>"
 446          fi
 447      else
 448          cd $dossier_ressource_dispositif_pxe_client_linux}
 449  
 450          if [ "$mode" = "cmdline" ]; then
 451              echo -e "$COLTXT"
 452          else
 453              echo "<b>"
 454          fi
 455          echo "Execution de la mise en place..."
 456          if [ "$mode" = "cmdline" ]; then
 457              echo -e "$COLCMD"
 458          else
 459              echo "</b>"
 460          fi
 461  
 462          chmod +x install_client_linux_mise_en_place.sh
 463          ./install_client_linux_mise_en_place.sh
 464  
 465          if [ "$?" != "0"  ]; then
 466  
 467              # ########################
 468              #        A FAIRE
 469              # Il faudrait effectuer un retour succes/erreur dans le install_client_linux_mise_en_place.sh
 470              # ########################
 471  
 472              if [ "$mode" = "cmdline" ]; then
 473                  echo -e "$COLERREUR"
 474              else
 475                  echo "<span style='color:red'>"
 476              fi
 477  
 478              echo "ERREUR lors de l execution de la mise en place."
 479  
 480              if [ "$mode" = "cmdline" ]; then
 481                  echo -e "$COLTXT"
 482              else
 483                  echo "</span>"
 484                  echo "</pre>"
 485              fi
 486          else
 487  
 488              SETMYSQL VarchPxeClientLin "$VarchPxeClientLin_en_ligne" "version actuelle archive du dispositif installation PXE client Linux" 7
 489              SETMYSQL VscriptPxeClientLin "$VscriptPxeClientLin_en_ligne" "version actuelle script de mise en place du dispositif installation PXE client Linux" 7
 490  
 491          fi
 492      fi
 493  fi
 494  
 495  rm -fr $tmp
 496  
 497  if [ "$mode" = "cmdline" ]; then
 498      echo -e "$COLTITRE"
 499  else
 500      echo "<b>"
 501  fi
 502  echo "Termine."
 503  if [ "$mode" = "cmdline" ]; then
 504      echo -e "$COLTXT"
 505  else
 506      echo "</b>"
 507      echo "</pre>"
 508  fi


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1