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 / process_web < prev    next >
Text File  |  2001-05-20  |  5KB  |  199 lines

  1. #!/bin/bash
  2. # $Id: process_web,v 1.4 2001/05/16 16:15:46 bzizou Exp $
  3.  
  4. # Web administration
  5.  
  6. # This script is part of the SLIS Project initiated by the CARMI-Internet
  7. # (AcadΘmie de Grenoble - France 38).
  8. # Ce script fait partie du projet SLIS dΘmarrΘ par le CARMI-Internet
  9. # (AcadΘmie de Grenoble - France 38).
  10. #
  11. # SLIS : Serveur de communications Linux Pour l'Internet Scolaire.
  12. # Copyright (C) 1999 Bruno Bzeznik
  13. #
  14. #    This program is free software; you can redistribute it and/or modify
  15. #    it under the terms of the GNU General Public License as published by
  16. #    the Free Software Foundation; either version 2 of the License, or
  17. #    (at your option) any later version.
  18. #
  19. #    This program is distributed in the hope that it will be useful,
  20. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22. #    GNU General Public License for more details.
  23. #    You should have received a copy of the GNU General Public License   
  24. #    along with this program (For example ./COPYING);
  25. #    if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  26. #    Cambridge, MA 02139, USA.
  27. #
  28. # Please send all comments and bug reports by electronic mail to: 
  29. #   Bruno Bzeznik <Bruno@ac-grenoble.fr>
  30. # or to <slis@ac-grenoble.fr>
  31. #    
  32. # Envoyez vos suggestions et reports de bugs par e-mail α
  33. #   Bruno Bzeznik <Bruno@ac-grenoble.fr>
  34. # ou α <slis@ac-grenoble.fr>
  35.  
  36.  
  37. . /home/hadmin/slis.conf
  38. LOG="/var/log/pushsite.log"
  39. LOG_WGET="/var/log/wget.log"
  40.  
  41. # Modification webmaster.
  42. if [ -f $QUEUE/webmaster ]
  43. then
  44.   WEBMASTER=`cat $QUEUE/webmaster`
  45.   export WEBMASTER
  46.  
  47. # Test if the SLIS is OK for that
  48.   if [ ! -f /bin/ftshell ]
  49.   then
  50.     ln -s /bin/false /bin/ftpshell
  51.   fi
  52.   ftpshell=`grep ftpshell /etc/shells`
  53.   if [ "$ftpshell" = "" ]
  54.   then
  55.     echo "/bin/ftpshell" >> /etc/shells
  56.   fi
  57.  
  58. # Debut du script en perl modifiant /etc/smb.conf
  59.   /usr/bin/perl <<"EOF"
  60. open (SMB,"/etc/smb.conf");
  61. open (TMP,">/tmp/_smb.conf_");
  62. $flag = 0;
  63. while (<SMB>) {
  64.   if (/^.*\[web].*$/) {$flag=1}
  65.   if ($flag == 1) {
  66.     if (/^.*\[.*\].*$/ && !(/^.*\[web].*$/)) {$flag=0; print TMP $_;}
  67.     else {
  68.     if (/^.*valid user.*$/) {
  69.       print TMP "        valid users     = ",$ENV{WEBMASTER},"\n";
  70.     }
  71.     else {print TMP $_}
  72.     }
  73.   }
  74.   else {print TMP $_}
  75. }
  76. close SMB;
  77. close TMP;
  78. EOF
  79. # Fin du script en perl modifiant /etc/smb.conf
  80.   mv -f /tmp/_smb.conf_ /etc/smb.conf
  81.   /etc/rc.d/init.d/smb restart
  82.  
  83.   # Modification des droits d'acces au repertoire du site.
  84.   chown -R $WEBMASTER /home/httpd/html
  85.   chmod -R 755 /home/httpd/html
  86.   mv -f $QUEUE/webmaster $BASE/webmaster
  87.   /usr/local/sbin/permslis
  88.  
  89.   # Modifications pour l'acces FTP et shell
  90.     # Les eventuels anciens webmaster deviennent utilisateurs normaux
  91.   grep "/home/httpd/html" /etc/passwd > /tmp/_passwd
  92.   if [ -s /tmp/_passwd ]
  93.   then
  94.     for i in `awk -F: '{print $1}' /tmp/_passwd`
  95.     do
  96.       usermod -d /home/$i -s /bin/false $i
  97.     done
  98.   fi
  99.   rm -rf /tmp/_passwd
  100.     # Le webmaster a son home dans /home/httpd/html et il a un shell specifique
  101.   usermod -d /home/httpd/html -s /bin/ftpshell $WEBMASTER
  102. fi
  103.  
  104. # Replication.
  105. if [ -f $QUEUE/webreplic ]
  106. then
  107.  
  108.   ## REPLICATION DU SITE PUBLIC
  109.   #############################
  110.  
  111.   # Configuration
  112.   if [ -f $QUEUE/pushsite.slis ]
  113.   then
  114.     mv -f $QUEUE/pushsite.slis $BASE/pushsite.slis
  115.     $SLIS_BINDIR/mkpushsiteconf
  116.   fi
  117.  
  118.   # Lancement
  119.   if [ -f $QUEUE/pushsite.start ]
  120.   then
  121.     $SLIS_BINDIR/lance_pushsite&
  122.     rm -rf $QUEUE/pushsite.start
  123.   fi
  124.  
  125.   # Abandon
  126.   if [ -f $QUEUE/pushsite.stop ]
  127.   then
  128.     date=`date`
  129.     echo "$date : ABANDON demande par l'administrateur SLIS." >> $LOG
  130.     killall pushsite
  131.     killall ftp
  132.     rm -rf $QUEUE/pushsite.stop
  133.   fi
  134.  
  135.   # Purge du log
  136.   if [ -f $QUEUE/pushsite.purge ]
  137.   then
  138.     cp /dev/null $LOG
  139.     rm -rf $QUEUE/pushsite.purge
  140.   fi
  141.  
  142.   ## ASPIRATION DE SITES
  143.   #############################
  144.  
  145.   # Configuration
  146.   if [ -f $QUEUE/wget.slis ]
  147.   then
  148.     mv -f $QUEUE/wget.slis $BASE/wget.slis
  149.     mv -f $QUEUE/wget-auto.slis $BASE/wget-auto.slis
  150.     $SLIS_BINDIR/mkwgetlauncher
  151.   fi
  152.  
  153.   # Lancement
  154.   if [ -f $QUEUE/wget.start ]
  155.   then
  156.     $SLIS_BINDIR/launch_wget&
  157.     rm -rf $QUEUE/wget.start
  158.   fi
  159.  
  160.   # Abandon
  161.   if [ -f $QUEUE/wget.stop ]
  162.   then
  163.     date=`date`
  164.     echo "$date : ABANDON demande par l'administrateur SLIS." >> $LOG_WGET
  165.     killall launch_wget
  166.     killall wget
  167.     WEBMASTER=`ls -ld /home/httpd/html |awk '{print $3}'`
  168.     chown -R $WEBMASTER /home/httpd/html/miroirs
  169.     rm -rf /var/lock/slis.wget
  170.     rm -rf $QUEUE/wget.stop
  171.   fi
  172.  
  173.   # Purge du log
  174.   if [ -f $QUEUE/wget.purge ]
  175.   then
  176.     cp /dev/null $LOG_WGET
  177.     rm -rf $QUEUE/wget.purge
  178.   fi
  179.  
  180.   # Suppression d'un site aspire
  181.   if [ -f $QUEUE/wget.del ]
  182.   then
  183.     for i in `cat $QUEUE/wget.del`
  184.     do
  185.       if [ $i != "" ]
  186.       then
  187.         R=$RANDOM
  188.         rm -rf /home/httpd/html/miroirs/$i
  189.         grep -v $i /home/httpd/html/miroirs/.miroirs > /tmp/.miroirs.$R
  190.         mv -f /tmp/.miroirs.$R /home/httpd/html/miroirs/.miroirs
  191.       fi
  192.     done
  193.     rm -rf $QUEUE/wget.del
  194.   fi
  195.   
  196.   # Suppression du drapeau
  197.   rm -rf $QUEUE/webreplic
  198. fi
  199.