[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/tftp-tools/install-clients-linux/ -> install_client_linux_mise_en_place.sh (source)

   1  #!/bin/bash
   2  
   3  
   4  # lastupdate 12-10-2014
   5  
   6  LADATE=$(date +%Y%m%d%H%M%S)
   7   
   8   
   9  # quelques couleurs ;-)
  10  rouge='\e[0;31m'
  11  rose='\e[1;31m'
  12  COLTITRE='\e[0;33m'
  13  jaune='\e[1;33m'
  14  vert='\e[0;32m'
  15  bleu='\e[1;34m'
  16  neutre='\e[0;m'
  17  
  18  # echo -e "$COLTITRE"
  19  echo "---------------------------------------------------------------------"
  20  echo "--------------         Mise en place du systeme      ----------------"
  21  echo "------------------------------------------------- -------------------"
  22  # echo -e "$vert"
  23  # echo "- Choisir le mode expert pour avoir toutes les possibilités d'installation coté clients"
  24  # echo "- Choisir le mode standard  pour avoir uniquement la possibilité d'installer xfce en mode auto"
  25  # echo -e "$neutre"
  26  # echo "Appuyez sur Entree pour continuer"
  27  # read -t 10 dummy
  28  #  
  29   
  30  #echo "---- Mode (e)xpert ou (s)tandard ? --- e/s"
  31  #read -t 10 CHOIX
  32  #CHOIX=e
  33  
  34   
  35  if egrep -q "^6.0" /etc/debian_version; then
  36      echo "Votre serveur est bien version Debian Squeeze"
  37      echo "Le script peut se poursuivre"
  38  else
  39      echo "Votre serveur n'est pas en version Squeeze."
  40      echo "Operation annulee !"
  41      exit 1
  42  fi
  43   
  44   
  45  # [ "$1" = "miroir-local" ] && MIROIR_LOCAL="yes"
  46    
  47  # Chemin source 
  48  src="$(pwd)"
  49  
  50  . /etc/se3/config_c.cache.sh
  51  . /etc/se3/config_d.cache.sh
  52  . /etc/se3/config_m.cache.sh
  53  . /etc/se3/config_l.cache.sh
  54  . /etc/se3/config_s.cache.sh
  55  
  56  # Pour recuperer la valeur MIROIR_LOCAL,... dans se3db
  57  . /etc/se3/config_o.cache.sh
  58  
  59  . /usr/share/se3/includes/functions.inc.sh 
  60  
  61  [ -e /root/debug ] && DEBUG="yes"
  62  
  63  # Lire la valeur de MIROIR_LOCAL et MIROIR_IP et CHEMIN_MIROIR dans la base MySQL ?
  64  MIROIR_LOCAL=$(echo "SELECT value FROM params WHERE name='MiroirAptCliLin';"|mysql -N $dbname -u$dbuser -p$dbpass)
  65  if [ "$MIROIR_LOCAL" = "yes" ]; then
  66      MIROIR_IP=$(echo "SELECT value FROM params WHERE name='MiroirAptCliLinIP';"|mysql -N $dbname -u$dbuser -p$dbpass)
  67      CHEMIN_MIROIR=$(echo "SELECT value FROM params WHERE name='MiroirAptCliLinChem';"|mysql -N $dbname -u$dbuser -p$dbpass)
  68  fi
  69  
  70  CliLinNoPreseed=$(echo "SELECT value FROM params WHERE name='CliLinNoPreseed';"|mysql -N $dbname -u$dbuser -p$dbpass)
  71  CliLinXfce64=$(echo "SELECT value FROM params WHERE name='CliLinXfce64';"|mysql -N $dbname -u$dbuser -p$dbpass)
  72  CliLinLXDE=$(echo "SELECT value FROM params WHERE name='CliLinLXDE';"|mysql -N $dbname -u$dbuser -p$dbpass)
  73  CliLinGNOME=$(echo "SELECT value FROM params WHERE name='CliLinGNOME';"|mysql -N $dbname -u$dbuser -p$dbpass)
  74  
  75  
  76  echo "Extraction de install_client_linux_archive-tftp.tar.gz."
  77  tar -xzf ./install_client_linux_archive-tftp.tar.gz
  78  
  79  if [ "$?" != "0" ]; then
  80      echo "Erreur lors de l'extraction de l'archive."
  81      exit 1
  82  fi
  83  
  84  # verif présence se3-clonage
  85  if [ ! -e "/usr/share/se3/scripts/se3_pxe_menu_ou_pas.sh" ]; then
  86      echo "installation du module Clonage"
  87      /usr/share/se3/scripts/install_se3-module.sh se3-clonage
  88  fi
  89  
  90  # verif présence paquet client-linux
  91  clients_linux_path="/home/netlogon/clients-linux"
  92  if [ ! -e "$clients_linux_path" ]; then
  93      apt-get install se3-clients-linux -y --force-yes
  94  fi
  95  
  96  # rights fix and directories
  97  setfacl -m u:www-data:rx $clients_linux_path
  98  setfacl -m d:u:www-data:rx $clients_linux_path
  99  
 100  
 101  chmod 777 /tmp
 102  
 103  rm -rf /home/netlogon/clients-linux/install
 104  rm -rf /var/www/install
 105  repinstall="/home/netlogon/clients-linux/install"
 106  replink="/var/www/install"
 107  
 108  mkdir -p $repinstall
 109  chmod 755 $repinstall
 110  
 111  chown root $repinstall
 112  ln -s $repinstall $replink
 113  
 114  
 115  
 116  # verif présence mkpasswd
 117  if [ ! -e "/usr/bin/mkpasswd" ]; then
 118      apt-get install whois -y
 119  fi
 120  
 121  # ===============================================================================================
 122  # On verifie si le menu Install fait reference ou non a debian-installer
 123  t=$(grep "Installation Debian" /tftpboot/tftp_modeles_pxelinux.cfg/menu/install.menu)
 124  t2=$(grep "Installation Ubuntu" /tftpboot/tftp_modeles_pxelinux.cfg/menu/install.menu)
 125  if [ -z "$t" ] ; then
 126    echo "   LABEL Installation Debian wheezy
 127      MENU LABEL ^Installation Debian
 128      KERNEL menu.c32
 129      APPEND pxelinux.cfg/inst_wheezy.cfg
 130  " >> /tftpboot/tftp_modeles_pxelinux.cfg/menu/install.menu
 131  fi
 132  
 133  if [ -z "$t2" ] ; then
 134  echo "    
 135      LABEL Installation Ubuntu et xubuntu trusty
 136      MENU LABEL ^Installation ubuntu
 137      KERNEL menu.c32
 138      APPEND pxelinux.cfg/inst_buntu.cfg   
 139  " >> /tftpboot/tftp_modeles_pxelinux.cfg/menu/install.menu
 140  # cp $src/install.menu /tftpboot/tftp_modeles_pxelinux.cfg/menu/
 141  fi
 142  
 143  if [ -e /tftpboot/pxelinux.cfg/install.menu ]; then
 144      t=$(grep "Installation Debian" /tftpboot/pxelinux.cfg/install.menu)
 145      t=$(grep "Installation Ubuntu" /tftpboot/pxelinux.cfg/install.menu)
 146      if [ -z "$t" ]; then
 147          cp /tftpboot/pxelinux.cfg/install.menu /tftpboot/pxelinux.cfg/install.menu.$LADATE
 148          cp /tftpboot/tftp_modeles_pxelinux.cfg/menu/install.menu /tftpboot/pxelinux.cfg/
 149      fi
 150  else
 151      if [ ! -e "/tftpboot/pxelinux.cfg/maintenance.menu" ]; then
 152          echo "Le menu d installation Debian n est propose qu avec le menu tftp semi-graphique."
 153          echo "configuration du mode semi-graphique"
 154          echo "Mise en place du mot de passe temporaire ci-dessous pour acceder au menu maintenance"
 155          CHANGEMYSQL "tftp_pass_menu_pxe" "Linux" 
 156          echo "----> Linux <----- mis en place. A changer au plus vite depuis l'interface de configuration tftp"
 157          sleep 5
 158          /usr/share/se3/scripts/set_password_menu_tftp.sh Linux
 159      fi
 160  fi
 161  cp $src/inst_wheezy.cfg $src/inst_buntu.cfg /tftpboot/pxelinux.cfg/
 162  # ===============================================================================================
 163  
 164  # ===============================================================================================
 165  # echo "Menage prealable"
 166  rm -fr /tftpboot/debian-installer
 167  rm -fr /tftpboot/ubuntu-installer
 168  
 169  
 170  echo "Telechargement du paquet netboot debian wheezy..."
 171  cd /root
 172  
 173  if [ "$DEBUG" = "yes" ]; then
 174      if [ -e "netboot-debian.tar.gz" ] && [ -e "netboot64-debian.tar.gz" ] && [ -e "netboot-ubuntu.tar.gz" ] ; then
 175          echo "Fichier netboot PXE existants sur le serveur" 
 176  #     cp $src/install.menu /tftpboot/tftp_modeles_pxelinux.cfg/menu/
 177      else 
 178          rm -f netboot*.tar.gz
 179          wget http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-i386/current/images/netboot/netboot.tar.gz -O netboot-debian.tar.gz    
 180          wget http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/current/images/netboot/netboot.tar.gz -O netboot64-debian.tar.gz
 181          wget http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-i386/current/images/netboot/netboot.tar.gz -O netboot-ubuntu.tar.gz
 182      fi
 183  
 184  else
 185      rm -f netboot*.tar.gz
 186      wget http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-i386/current/images/netboot/netboot.tar.gz -O netboot-debian.tar.gz    
 187      wget http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/current/images/netboot/netboot.tar.gz -O netboot64-debian.tar.gz
 188      wget http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-i386/current/images/netboot/netboot.tar.gz -O netboot-ubuntu.tar.gz
 189  fi
 190  
 191  
 192  echo "extraction du fichier netboot.tar.gz" 
 193  tar -xzf netboot-debian.tar.gz
 194  tar -xzf netboot64-debian.tar.gz
 195  tar -xzf netboot-ubuntu.tar.gz
 196  
 197  mv debian-installer /tftpboot/
 198  mv ubuntu-installer /tftpboot/
 199  rm -f /root/pxelinux.0 /root/pxelinux.cfg /root/version.info
 200  
 201  
 202  # http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-i386/current/images/netboot/netboot.tar.gz
 203  
 204  
 205  cp $src/post-install* $src/preseed*.cfg $src/mesapplis*.txt $src/bashrc $src/inittab $src/tty1.conf /var/remote_adm/.ssh/id_rsa.pub /var/www/install/
 206  chmod 755 /var/www/install/preseed* /var/www/install/post-install_debian_wheezy.sh
 207  
 208  if [ -e "/home/netlogon/clients-linux/distribs/wheezy/integration/integration_wheezy.bash" ]; then
 209      cp /home/netlogon/clients-linux/distribs/wheezy/integration/integration_wheezy.bash /var/www/install/
 210      chmod 755 /var/www/install/integration_wheezy.bash
 211  fi
 212  # ===============================================================================================
 213  rm -f /var/www/paquet_cles_pub_ssh.tar.gz
 214  if [ ! -e "/var/www/paquet_cles_pub_ssh.tar.gz" ]; then
 215      echo "Generation d un paquet de cles pub ssh d apres vos authorized_keys"
 216      cd /root/.ssh
 217      for fich_authorized_keys in authorized_keys authorized_keys2 /var/www/install/id_rsa.pub 
 218      do
 219          if [ -e "$fich_authorized_keys" ]; then
 220              while read A
 221              do
 222                  comment=$(echo "$A"|cut -d" " -f3)
 223                  if [ -n "$comment" -a ! -e "$comment.pub" ]; then
 224                      echo "$A" > $comment.pub
 225                  fi
 226              done < $fich_authorized_keys
 227          fi
 228      done
 229      tar -czf /var/www/paquet_cles_pub_ssh.tar.gz *.pub
 230  fi
 231  
 232  
 233  
 234  # ===============================================================================================
 235  
 236  CRYPTPASS="$(echo "$xppass" | mkpasswd -s -m md5)"
 237  [ -z "$ntpserv" ] && ntpserv="ntp.ac-creteil.fr"
 238  
 239  echo "Correction du fichier TFTP inst_inst_wheezy.cfg pour ajout IP du Se3"
 240  
 241  
 242  sed -i "s|###_IP_SE3_###|$se3ip|g" /tftpboot/pxelinux.cfg/inst_wheezy.cfg 
 243  sed -i "s|###_IP_SE3_###|$se3ip|g" /tftpboot/pxelinux.cfg/inst_buntu.cfg 
 244  
 245  [ "$CliLinNoPreseed" = "yes" ] && sed -i "s|^#INSTALL_LIBRE_SANS_PRESEED||" /tftpboot/pxelinux.cfg/inst_wheezy.cfg 
 246  [ "$CliLinNoPreseed" = "yes" ] && sed -i "s|^#INSTALL_LIBRE_SANS_PRESEED||" /tftpboot/pxelinux.cfg/inst_buntu.cfg 
 247  
 248  [ "$CliLinXfce64" = "yes" ] && sed -i "s|^#XFCE64||" /tftpboot/pxelinux.cfg/inst_wheezy.cfg 
 249  [ "$CliLinXfce64" = "yes" ] && sed -i "s|^#XFCE64||" /tftpboot/pxelinux.cfg/inst_buntu.cfg 
 250  
 251  [ "$CliLinLXDE" = "yes" ] && sed -i "s|^#LXDE||" /tftpboot/pxelinux.cfg/inst_wheezy.cfg 
 252  [ "$CliLinLXDE" = "yes" ] && sed -i "s|^#LXDE||" /tftpboot/pxelinux.cfg/inst_buntu.cfg 
 253  
 254  [ "$CliLinGNOME" = "yes" ] && sed -i "s|^#GNOME||" /tftpboot/pxelinux.cfg/inst_wheezy.cfg 
 255  [ "$CliLinGNOME" = "yes" ] && sed -i "s|^#GNOME||" /tftpboot/pxelinux.cfg/inst_buntu.cfg 
 256  
 257  if [ "$MIROIR_LOCAL" != "yes" ]; then
 258      echo "Installation et configuration de apt-cacher-ng pour se3"
 259      echo "Le cache sera dans /var/se3/apt-cacher-ng"
 260      apt-get install apt-cacher-ng -y
 261      rm -f /etc/apt-cacher-ng/acng.conf.*
 262      mv /etc/apt-cacher-ng/acng.conf /etc/apt-cacher-ng/acng.conf.$LADATE
 263      cat > /etc/apt-cacher-ng/acng.conf <<END
 264  CacheDir: /var/se3/apt-cacher-ng
 265  LogDir: /var/log/apt-cacher-ng
 266  Port:9999
 267  Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian
 268  Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu
 269  Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol
 270  Remap-cygwin: file:cygwin_mirrors /cygwin # ; file:backends_cygwin # incomplete, please create this file
 271  ReportPage: acng-report.html
 272  VerboseLog: 1
 273  ExTreshold: 4
 274  END
 275  
 276      # securisation acces admin pass adminse3
 277      echo "AdminAuth: admin:$xppass" > /etc/apt-cacher-ng/security.conf 
 278      chown apt-cacher-ng:apt-cacher-ng /etc/apt-cacher-ng/security.conf 
 279      chmod 600 /etc/apt-cacher-ng/security.conf 
 280  
 281      # config propre ubuntu
 282      echo "http://fr.archive.ubuntu.com/ubuntu/" > /etc/apt-cacher-ng/backends_ubuntu
 283  
 284      
 285      if [ ! -e /var/se3/apt-cacher-ng ]; then 
 286          mv /var/cache/apt-cacher-ng /var/se3/
 287      fi
 288  
 289      service apt-cacher-ng restart
 290      
 291      
 292      echo "Correction des fichiers de preseed wheezy"
 293  
 294  
 295      for i in $(ls /var/www/install/preseed*.cfg)
 296      do
 297          sed -i "s|###_IP_SE3_###|$se3ip|g" $i
 298          sed -i "s|###_PASS_ROOT_###|$CRYPTPASS|g" $i
 299          sed -i "s|###_NTP_SERV_###|$ntpserv|g" $i 
 300      done
 301  else
 302      if [ -z "$MIROIR_IP" -o -z "$CHEMIN_MIROIR" ]; then
 303          echo "--- Adresse du miroir ?"
 304          read MIROIR_IP
 305          echo "--- Chemin dans le miroir ?"
 306          read CHEMIN_MIROIR
 307      fi
 308  
 309      echo "Correction des fichiers de preseed wheezy"
 310  
 311      for i in $(ls /var/www/install/preseed*.cfg)
 312      do
 313          sed -i "s|###_IP_SE3_###:9999|$MIROIR_IP|g" $i
 314          sed -i "s|###_IP_SE3_###|$se3ip|g" $i
 315          sed -i "s|/debian|$CHEMIN_MIROIR|g" $i 
 316          sed -i "s|###_PASS_ROOT_###|$CRYPTPASS|g" $i
 317          sed -i "s|###_NTP_SERV_###|$ntpserv|g" $i 
 318      done
 319  fi
 320  
 321  
 322  
 323  
 324  
 325  
 326  
 327  email=$(grep "^root=" /etc/ssmtp/ssmtp.conf |cut -d"=" -f2)
 328  if [ -z "$email" ]; then
 329      email=root
 330  fi
 331  
 332  mailhub=$(grep "^mailhub=" /etc/ssmtp/ssmtp.conf |cut -d"=" -f2)
 333  if [ -z "$mailhub" ]; then
 334      mailhub=mail
 335  fi
 336  
 337  rewriteDomain=$(grep "^rewriteDomain=" /etc/ssmtp/ssmtp.conf |cut -d"=" -f2)
 338  if [ -z "$rewriteDomain" ]; then
 339      rewriteDomain=$dhcp_domain_name
 340  fi
 341  
 342  tmp_proxy=$(cat /etc/profile | grep http_proxy= | cut -d= -f2|sed -e 's|"||g'|sed -e "s|.*//||")
 343  ip_proxy=$(echo "$tmp_proxy"|cut -d":" -f1)
 344  port_proxy=$(echo "$tmp_proxy"|cut -d":" -f2)
 345  
 346  
 347  echo "Generation du fichier de parametres /var/www/install/params.sh"
 348  
 349  cat > /var/www/install/params.sh << END
 350  email="$email"
 351  mailhub="$mailhub"
 352  rewriteDomain="$rewriteDomain"
 353  
 354  # Parametres Proxy:
 355  ip_proxy="$ip_proxy"
 356  port_proxy="$port_proxy"
 357  
 358  # Parametres SE3:
 359  ip_se3="$se3ip"
 360  nom_se3="$(hostname)"
 361  nom_domaine="$dhcp_domain_name"
 362  ocs="$inventaire"
 363  
 364  # Parametres LDAP:
 365  ip_ldap="$ldap_server"
 366  ldap_base_dn="$ldap_base_dn"
 367  END
 368  
 369  chmod 755 /var/www/install/params.sh
 370  
 371  [ -e /home/netlogon/clients-linux/unefois/PAUSE ] && mv /home/netlogon/clients-linux/unefois/PAUSE /home/netlogon/clients-linux/unefois/NO-PAUSE
 372  cp -r $src/unefois/* /home/netlogon/clients-linux/unefois/
 373  cp /home/netlogon/clients-linux/bin/logon_perso /home/netlogon/clients-linux/bin/logon_perso-$LADATE
 374  sed -i -r '/initialisation_perso[[:space:]]*\(\)/,/^\}/s/^([[:space:]]*)true/\1activer_pave_numerique/' /home/netlogon/clients-linux/bin/logon_perso
 375  # cp $src/logon_perso /home/netlogon/clients-linux/bin/
 376  
 377  # if [ -e /home/netlogon/clients-linux/distribs/wheezy/skel/.config ];then
 378  #     rm -rf /home/netlogon/clients-linux/distribs/wheezy/skel/config-save*
 379  #     mv /home/netlogon/clients-linux/distribs/wheezy/skel/.config /home/netlogon/clients-linux/distribs/wheezy/skel/config-save-$LADATE
 380  # fi
 381  
 382  # if [ -e /home/netlogon/clients-linux/distribs/wheezy/skel/.mozilla ];then
 383  #     rm -rf /home/netlogon/clients-linux/distribs/wheezy/skel/mozilla-save*
 384  #     mv /home/netlogon/clients-linux/distribs/wheezy/skel/.mozilla /home/netlogon/clients-linux/distribs/wheezy/skel/mozilla-save-$LADATE
 385  # fi
 386  
 387  [ ! -e /home/netlogon/clients-linux/distribs/wheezy/skel/.config ] && cp -r $src/.config /home/netlogon/clients-linux/distribs/wheezy/skel/
 388  [ ! -e /home/netlogon/clients-linux/distribs/wheezy/skel/.mozilla ]&& cp -r $src/.mozilla /home/netlogon/clients-linux/distribs/wheezy/skel/
 389   
 390  # cp -r  $src/.config $src/.mozilla /home/netlogon/clients-linux/distribs/wheezy/skel/
 391  rm -f /home/netlogon/clients-linux/distribs/wheezy/skel/.mozilla/firefox/default/prefs.js-save*
 392  mv /home/netlogon/clients-linux/distribs/wheezy/skel/.mozilla/firefox/default/prefs.js /home/netlogon/clients-linux/distribs/wheezy/skel/.mozilla/firefox/default/prefs.js-save-$LADATE
 393  cp /etc/skel/user/profil/appdata/Mozilla/Firefox/Profiles/default/prefs.js /home/netlogon/clients-linux/distribs/wheezy/skel/.mozilla/firefox/default/
 394  
 395   
 396  if [ ! -e /home/netlogon/clients-linux/unefois/\^\. ]; then
 397    mv /home/netlogon/clients-linux/unefois/all /home/netlogon/clients-linux/unefois/\^\.
 398  else
 399    cp /home/netlogon/clients-linux/unefois/all/* /home/netlogon/clients-linux/unefois/\^\./
 400    rm -rf /home/netlogon/clients-linux/unefois/all
 401  fi 
 402  [ -e /home/netlogon/clients-linux/unefois/\^\* ] && mv /home/netlogon/clients-linux/unefois/\^\*/*  /home/netlogon/clients-linux/unefois/\^\./
 403  rm -rf /home/netlogon/clients-linux/unefois/\^\*
 404    
 405  
 406  bash /home/netlogon/clients-linux/.defaut/reconfigure.bash 
 407  


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