home *** CD-ROM | disk | FTP | other *** search
/ ftp.ac-grenoble.fr / 2015.02.ftp.ac-grenoble.fr.tar / ftp.ac-grenoble.fr / pub / slis / updates_rsync / slis_update-common < prev    next >
Text File  |  2001-12-02  |  16KB  |  515 lines

  1. #!/bin/bash
  2.  
  3. # slis_update-common
  4. # Script de mise α jour tΘlΘchargΘ rΘguliΦrement par rsync par tous les
  5. # serveurs SLIS
  6.  
  7. # This script is part of the SLIS Project initiated by the CARMI-Internet
  8. # (AcadΘmie de Grenoble - France 38).
  9. # Ce script fait partie du projet SLIS dΘmarrΘ par le CARMI-Internet
  10. # (AcadΘmie de Grenoble - France 38).
  11. #
  12. # SLIS : Serveur de communications Linux pour l'Internet Scolaire.
  13. # Copyright (C) 1998-2000 Bruno Bzeznik
  14. #
  15. #    This program is free software; you can redistribute it and/or modify
  16. #    it under the terms of the GNU General Public License as published by
  17. #    the Free Software Foundation; either version 2 of the License, or
  18. #    (at your option) any later version.
  19. #
  20. #    This program is distributed in the hope that it will be useful,
  21. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23. #    GNU General Public License for more details.
  24. #    You should have received a copy of the GNU General Public License
  25. #    along with this program (For example ./COPYING);
  26. #    if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  27. #    Cambridge, MA 02139, USA.
  28. #
  29. # Please send all comments and bug reports by electronic mail to:
  30. #   Bruno Bzeznik <Bruno@ac-grenoble.fr>
  31. # or to <slis@ac-grenoble.fr>
  32. #
  33. # Envoyez vos suggestions et reports de bugs par e-mail α
  34. #   Bruno Bzeznik <Bruno@ac-grenoble.fr>
  35. # ou α <slis@ac-grenoble.fr>
  36. #
  37.  
  38. ### VARIABLES ###
  39. UPDDIR=/home/hadmin/updates # Rep pour les flags
  40. LOGTAG="slis_update[$$]" # Ce qui apparait en syslog
  41. PAS_UPD_KERNEL=0        # Si ce flag est a un, alors la mise a jour du noyau
  42.                 # (qui necessite reboot) ne sera pas faite cette fois.
  43. # Recuperation de la variable HOSTNAME :
  44. grep HOSTNAME /etc/sysconfig/network > /tmp/hostname
  45. . /tmp/hostname
  46. rm -rf /tmp/hostname
  47.  
  48. WEBMASTER=`ls -ld /home/httpd/html |awk '{print $3}'` # Webmaster designΘ par l'admin local
  49.  
  50. . /home/hadmin/slis.conf
  51.  
  52. ##################
  53.  
  54. # Gestion d'un lock
  55. if [ -e /var/lock/slis_upd ]
  56. then 
  57.   logger -t "$LOGTAG" "Deja en cours. Abandon."
  58.   exit
  59. fi
  60. touch /var/lock/slis_upd
  61. sleep 1
  62.  
  63. logger -t "$LOGTAG" "Script Commun Debut"
  64.  
  65. # Refaire clignoter la led isdn pour le slis version isdn
  66. if [ -e /root/slis/setup.data ]
  67. then
  68.   . /root/slis/setup.data
  69. fi
  70. if [ "$ISDN" = "1" ]
  71. then
  72.   $SLIS_BINDIR/isdnled tty1 -k
  73.   $SLIS_BINDIR/netled tty1 ippp0 -k
  74.   sleep 1
  75.   $SLIS_BINDIR/isdnled tty1 -d
  76.   $SLIS_BINDIR/netled tty1 ippp0 -d
  77. fi
  78.  
  79. ############################################################################
  80. ### Mise a jour 101 - 13/09/99
  81. # Mise a l'heure
  82. # Rend obsolete : 
  83. ############################################################################
  84.  
  85. if [ ! \( -e $UPDDIR/101 \) ]
  86. then
  87.   # Mise a l'heure du Bios
  88.   /usr/bin/rdate -s $RDATE_SERVER
  89.   /usr/sbin/setclock
  90.  
  91.   touch $UPDDIR/101
  92.   logger -t "$LOGTAG" "UPDATE 101 effectuee."
  93. fi
  94. ###
  95.  
  96. ############################################################################
  97. ### Mise a jour 134 - 02/05/2000
  98. # Nouveau squid_purge (bug de la MAJ 123 --> manque le lancement de prostat)
  99. # Rend obsolete : 123
  100. ############################################################################
  101.  
  102. if [ ! \( -e $UPDDIR/134 \) ]
  103. then
  104.   cd /usr/local/sbin
  105.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/squid_purge .
  106.   chmod 755 squid_purge
  107.  
  108.   touch $UPDDIR/134
  109.   logger -t "$LOGTAG" "UPDATE 134 effectuee"
  110. fi
  111. ###
  112.  
  113. ############################################################################
  114. ### Mise a jour 136 - 06/06/2000
  115. # Creation du fichier /etc/service.switch necessaire a sendmail
  116. # Cela evitera des connexions permanentes...
  117. # Rend obsolete : 
  118. ############################################################################
  119.  
  120. if [ ! \( -e $UPDDIR/136 \) ]
  121. then
  122.   echo "hosts files" > /etc/service.switch
  123.   echo "aliases files" >> /etc/service.switch
  124.   /etc/rc.d/init.d/sendmail restart
  125.  
  126.   touch $UPDDIR/136
  127.   logger -t "$LOGTAG" "UPDATE 136 effectuee" 
  128. fi
  129. ###
  130.  
  131. ############################################################################
  132. ### Mise a jour 138 - 04/07/2000
  133. # Amelioration de l'interface:
  134. # - fonction de suppression des users plus ergonomique
  135. # - ajout d'une fonction de visualisation des entetes des mails
  136. # Rend obsolete :
  137. ############################################################################
  138.  
  139. if [ ! \( -e $UPDDIR/138 \) ]
  140. then
  141.   /usr/sbin/usermod -G mail hadmin
  142.   killall -HUP httpd
  143.   cd /tmp
  144.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/upd-138.tgz .
  145.   cd /
  146.   tar zxf /tmp/upd-138.tgz
  147.   chown -R hadmin.hadmin /home/hadmin
  148.  
  149.   touch $UPDDIR/138
  150.   logger -t "$LOGTAG" "UPDATE 138 effectuee"
  151. fi
  152. ###
  153.  
  154.  
  155. ############################################################################
  156. ### Mise a jour C-1 - 16/09/2000
  157. # Bug de users_del* (possibilitΘ de suppression du compte named)
  158. # Rend obsolete :
  159. ############################################################################
  160.  
  161. if [ ! \( -e $UPDDIR/C-1 \) ]
  162. then
  163.   cd /tmp
  164.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/upd-C-1.tgz .
  165.   cd /
  166.   tar zxf /tmp/upd-C-1.tgz
  167.  
  168.   touch $UPDDIR/C-1
  169.   logger -t "$LOGTAG" "UPDATE C-1 effectuee"
  170. fi
  171. ###
  172.  
  173. ############################################################################
  174. ### Mise a jour C-2b - 26/09/2000
  175. # Nouvelle fonction: replication du web public
  176. # Rend obsolete : C-2
  177. ############################################################################
  178.  
  179. if [ ! \( -e $UPDDIR/C-2b \) ]
  180. then
  181.   cd /tmp
  182.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/upd-C-2.tgz .
  183.   cd /
  184.   tar zxf /tmp/upd-C-2.tgz
  185.   cd /usr/local/sbin
  186.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/rand60 .
  187.   chmod 755 rand60
  188.  
  189.   # Generation d'une heure de replication par defaut aleatoire
  190.   declare -i r
  191.   r=`/usr/local/sbin/rand60`
  192.   if [ $r -ge 0 -a $r -lt 10 ]; then h="21"; fi
  193.   if [ $r -ge 10 -a $r -lt 20 ]; then h="22"; fi
  194.   if [ $r -ge 20 -a $r -lt 30 ]; then h="23"; fi
  195.   if [ $r -ge 30 -a $r -lt 40 ]; then h="00"; fi
  196.   if [ $r -ge 40 -a $r -lt 50 ]; then h="01"; fi
  197.   if [ $r -ge 50 ]; then h="02"; fi
  198.   $SLIS_BINDIR/remplace 22 $h $BASE/pushsite.slis
  199.  
  200.   touch $UPDDIR/C-2b
  201.   logger -t "$LOGTAG" "UPDATE C-2b effectuee"
  202. fi
  203. ###
  204.  
  205. ############################################################################
  206. ### Mise a jour C-3b - 28/09/2000
  207. # Remise en etat de quelques modes
  208. # Rend obsolete : C-3 C-3a
  209. ############################################################################
  210.  
  211. if [ ! \( -e $UPDDIR/C-3b \) ]
  212. then
  213.  
  214.   chown -R root.root /usr/local/bin
  215.   chown -R root.root /usr/local/etc
  216.   chown hadmin.hadmin /home/hadmin
  217.   chown hadmin.hadmin /home/hadmin/*
  218.   chmod 755 /home/hadmin
  219.   chmod 750 /home/hadmin/*
  220.   chmod 755 /home/hadmin/slis.conf.pl
  221.   chmod 755 /usr/local/sbin/*
  222.   chmod 755 /usr/local/bin/*
  223.   
  224.   touch $UPDDIR/C-3b
  225.   logger -t "$LOGTAG" "UPDATE C-3b effectuee"
  226. fi
  227. ###
  228.  
  229. ############################################################################
  230. ### Mise a jour C-4b - 5/11/2000
  231. # Nouveaux scripts process_routage_net_on et process_routage_net_off plus
  232. # tolerants dans le cas o∙ d'autres filtres existeraient deja.
  233. # C4b: bug de C4: des fichiers restent dans /tmp
  234. # Rend obsolete : C-4
  235. ############################################################################
  236.  
  237. if [ ! \( -e $UPDDIR/C-4b \) ]
  238. then
  239.  
  240.   cd /tmp
  241.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/upd-C-4.tgz .
  242.   cd /
  243.   tar zxf /tmp/upd-C-4.tgz
  244.   rm -rf /tmp/ipfwadm-Iln.*
  245.  
  246.   touch $UPDDIR/C-4b
  247.   logger -t "$LOGTAG" "UPDATE C-4b effectuee"
  248. fi
  249. ###
  250.  
  251. ############################################################################
  252. ### Mise a jour C-6 - 29/01/2001
  253. # Mise a jour process_routage_net_on/off
  254. # Ajout d'un filtre qui laisse passer http vers les ip officielles locales
  255. # meme pour un sous-reseau dΘsactivΘ.
  256. # Rend obsolete :
  257. ############################################################################
  258.  
  259. if [ ! \( -e $UPDDIR/C-6 \) ]
  260. then
  261.   # Telechargement du tar
  262.   cd /tmp
  263.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/upd-C-6.tgz .
  264.   cd /
  265.   tar zxf /tmp/upd-C-6.tgz
  266.   RC=$?
  267.  
  268.   # Verification et fin de la MAJ
  269.   if [ $RC = 0 ]
  270.   then
  271.     touch $UPDDIR/C-6
  272.     logger -t "$LOGTAG" "Update C-6 effectuee."
  273.   else
  274.     logger -t "$LOGTAG" "Update C-6 ECHEC."
  275.   fi
  276. fi
  277. ###
  278.  
  279. ############################################################################
  280. ### Mise a jour C-7b - 08/02/2001
  281. # Creation du slis.conf.php
  282. # Rend obsolete : C-7
  283. ############################################################################
  284.  
  285. if [ ! \( -e $UPDDIR/C-7b \) ]
  286. then
  287.  
  288.   cd /home/hadmin/
  289.   echo -e "<?PHP\n" > slis.conf.php
  290.   grep "=" slis.conf.pl >> slis.conf.php
  291.   echo "\$LANGUAGE=\"french\"" >> slis.conf.php
  292.   echo -e "\n?>" >> slis.conf.php
  293.   chown hadmin.hadmin slis.conf.php
  294.   chmod 755 slis.conf.php
  295.  
  296.   touch $UPDDIR/C-7b
  297.   logger -t "$LOGTAG" "UPDATE C-7b effectuee"
  298. fi
  299. ### 
  300.  
  301. ############################################################################
  302. ### Mise a jour C-8 - 30/01/2001
  303. # Un peu de couleur pour les logs
  304. # Rend obsolete :
  305. ############################################################################
  306.  
  307. if [ ! \( -e $UPDDIR/C-8 \) ]
  308. then
  309.  
  310.   cd /tmp
  311.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/perl-ANSIColor-1.01-2.i386.rpm .
  312.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/loco-0.32-1.noarch.rpm .
  313.   rpm -U --nodeps perl-ANSIColor-1.01-2.i386.rpm
  314.   rpm -U --nodeps loco-0.32-1.noarch.rpm
  315.  
  316.   # Verifications et fin de l'install
  317.   rpm -q loco 2>/dev/null >/dev/null
  318.   RC=$?
  319.   if [ $RC = 0 ]
  320.   then
  321.     if [ "`rpm -qv perl |grep 5.005`" = "" ]
  322.     then
  323.       ln -s /usr/lib/perl5/site_perl/5.005/Term/ANSIColor.pm /usr/lib/perl5/Term/
  324.     fi
  325.     R=$RANDOM
  326.     cp -f /etc/rc.d/rc.local /etc/rc.d/rc.local.upd-C-8
  327.     sed "s;tail -f /var/log/messages >;tail -f /var/log/messages|loco >;" /etc/rc.d/rc.local > /tmp/rc.local.$R
  328.     mv -f /tmp/rc.local.$R /etc/rc.d/rc.local
  329.     chmod 755 /etc/rc.d/rc.local
  330.     killall tail
  331.     tail -f /var/log/messages|loco > /dev/console&
  332.     if [ "`grep \"tail -f \" /etc/rc.d/rc.local`" = "" ]
  333.     then
  334.       echo "tail -f /var/log/messages|loco > /dev/console&" >> /etc/rc.d/rc.local
  335.     fi
  336.     touch $UPDDIR/C-8
  337.     logger -t "$LOGTAG" "UPDATE C-8 effectuee"
  338.   else
  339.     logger -t "$LOGTAG" "UPDATE C-8 ECHEC."
  340.   fi
  341. fi
  342. ###
  343.  
  344. ############################################################################
  345. ### Mise a jour C-9 - 02/02/2001
  346. # Reprogrammation de cron pour une MAJ quotidienne au lieu d'hebdomadaire
  347. # Rend obsolete :
  348. ############################################################################
  349.  
  350. if [ ! \( -e $UPDDIR/C-9 \) ]
  351. then
  352.  
  353.   R=$RANDOM
  354.   crontab -l > /tmp/cron.$R
  355.   COUNT=`wc -l /tmp/cron.$R|awk '{print $1}'`
  356.   tail -`expr $COUNT - 3` /tmp/cron.$R|sed "s;\* 1.*/usr/local/sbin/slis_update.cron;\* \*    /usr/local/sbin/slis_update.cron;" > /tmp/cron.new.$R
  357.   rm -f /tmp/cron.$R
  358.  
  359.   # Verification et fin de la MAJ
  360.   if [ "`wc -l /tmp/cron.new.$R|awk '{print $1}'`" = "`expr $COUNT - 3`" ]
  361.   then
  362.     crontab /tmp/cron.new.$R
  363.     RC=$?
  364.     rm -f /tmp/cron.new.$R
  365.     if [ "$RC" = "0" ]
  366.     then
  367.       touch $UPDDIR/C-9
  368.       logger -t "$LOGTAG" "Update C-9 effectuee."
  369.     else
  370.       logger -t "$LOGTAG" "Update C-9 ECHEC."
  371.     fi
  372.   else
  373.     logger -t "$LOGTAG" "Update C-9 ECHEC."
  374.   fi
  375. fi
  376. ###
  377.  
  378. ############################################################################
  379. ### Mise a jour C-10 - 08/02/2001
  380. # Nouveau slis.pac (conf automatique proxy)
  381. # Rend obsolete :
  382. ############################################################################
  383.  
  384. if [ ! \( -e $UPDDIR/C-10 \) ]
  385. then
  386.   # Telechargement du tar
  387.   cd /tmp
  388.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/upd-C-10.tgz .
  389.   cd /
  390.   tar zxf /tmp/upd-C-10.tgz
  391.   RC=$?
  392.  
  393.   # Verification et fin de la MAJ
  394.   if [ $RC = 0 ]
  395.   then
  396.     touch $UPDDIR/C-10
  397.     logger -t "$LOGTAG" "Update C-10 effectuee."
  398.   else
  399.     logger -t "$LOGTAG" "Update C-10 ECHEC."
  400.   fi
  401. fi
  402. ###
  403.  
  404.  
  405.  
  406.  
  407. ############################################################################
  408. ### Update C-16 - 01/10/2001
  409. # New update script with a better locking and "freeze" checking
  410. # Obsoletes :
  411. ############################################################################
  412.  
  413. if [ ! \( -e $UPDDIR/C-16 \) ]
  414. then
  415.   # Telechargement du tar
  416.   cd /tmp
  417.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/upd-C-16.tgz .
  418.   cd /
  419.   tar zxf /tmp/upd-C-16.tgz
  420.   RC1=$?
  421.   /usr/local/sbin/permslis
  422.   chmod 755 /usr/local/sbin/slis_update
  423.  
  424.   # Cron modification
  425.   R=$RANDOM
  426.   crontab -l > /tmp/cron.$R
  427.   COUNT=`wc -l /tmp/cron.$R|awk '{print $1}'`
  428.   tail -`expr $COUNT - 3` /tmp/cron.$R|sed "s;slis_update\.cron;slis_update;" > /tmp/cron.new.$R
  429.   rm -f /tmp/cron.$R
  430.   if [ "`wc -l /tmp/cron.new.$R|awk '{print $1}'`" = "`expr $COUNT - 3`" ]
  431.   then
  432.     crontab /tmp/cron.new.$R
  433.     RC2=$?
  434.     rm -f /tmp/cron.new.$R
  435.   fi
  436.  
  437.   # Verification et fin de la MAJ
  438.   if [ $RC1 = 0 -a $RC2 = 0 ]
  439.   then
  440.     touch $UPDDIR/C-16
  441.     mv /usr/local/sbin/slis_update.cron /usr/local/sbin/slis_update.cron.obsolete
  442.     logger -t "$LOGTAG" "Update C-16 done."
  443.   else
  444.     logger -t "$LOGTAG" "Update C-16 FAILED."
  445.   fi
  446. fi
  447. ###
  448.  
  449. ############################################################################
  450. ### Update C-16b - 03/10/2001
  451. # Fixes a little bug of C16 (obsolete use of slis_update.cron in rc.local)
  452. # Obsoletes :
  453. ############################################################################
  454.  
  455. if [ ! \( -e $UPDDIR/C-16b \) ]
  456. then
  457.  
  458.   R=$RANDOM
  459.   sed "s;slis_update\.cron;slis_update;" /etc/rc.d/rc.local > /tmp/rc.local.$R
  460.   cp -f /etc/rc.d/rc.local /etc/rc.d/rc.local.C-16b
  461.   mv -f /tmp/rc.local.$R /etc/rc.d/rc.local
  462.   chmod 755 /etc/rc.d/rc.local
  463.  
  464.   touch $UPDDIR/C-16b
  465.   logger -t "$LOGTAG" "Update C-16b done."
  466. fi
  467. ###
  468.  
  469.  
  470. ############################################################################
  471. ### Mise a jour BASES SQUIDGUARD - Permanente (toutes les semaines)
  472. # ATTENTION: Laisser cette UPD en fin de fichier, avant les UPD KERNEL.
  473. # Il faut mirrorrer 
  474. # ftp://ftp.univ-tlse1.fr/pub/reseau/cache/squidguard_contrib 
  475. # dans le rep tftp des MAJ SLIS.
  476. # Il faut aussi maintenir la base academie.tar.gz
  477. ############################################################################
  478.  
  479. if [ -e /usr/local/squid/squidGuard/db ]
  480. then
  481.   logger -t "$LOGTAG" "RECUPERATION BASES FILTRES URL: debut"
  482.   cd /usr/local/squid/squidGuard/db
  483.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/adult.tar.gz .
  484.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/warez.tar.gz .
  485.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/forums.tar.gz .
  486.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/publicite.tar.gz .
  487.   rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/academie.tar.gz .
  488.   logger -t "$LOGTAG" "Installation des bases."
  489.   tar zxf adult.tar.gz
  490.   tar zxf warez.tar.gz
  491.   tar zxf forums.tar.gz
  492.   tar zxf publicite.tar.gz
  493.   tar zxf academie.tar.gz
  494.   chown -R nobody.nobody *
  495.   /usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/adult/domains
  496.   /usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/adult/urls
  497.   /usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/warez/domains
  498.   /usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/warez/urls
  499.   /usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/forums/domains
  500.   /usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/forums/urls
  501.   /usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/publicite/domains
  502.   /usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/publicite/urls
  503.   /usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/academie/domains
  504.   /usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/academie/urls
  505.   logger -t "$LOGTAG" "Redemarrage du cache."
  506.   killall -HUP squid
  507.   logger -t "$LOGTAG" "RECUPERATION BASES FILTRES URL: fin"
  508. fi
  509. ###
  510.  
  511. ##############################
  512. logger -t "$LOGTAG" "Script Commun Termine."
  513.  
  514. /bin/rm -rf /var/lock/slis_upd
  515.