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 >
Wrap
Text File
|
2001-05-20
|
5KB
|
199 lines
#!/bin/bash
# $Id: process_web,v 1.4 2001/05/16 16:15:46 bzizou Exp $
# Web administration
# This script is part of the SLIS Project initiated by the CARMI-Internet
# (AcadΘmie de Grenoble - France 38).
# Ce script fait partie du projet SLIS dΘmarrΘ par le CARMI-Internet
# (AcadΘmie de Grenoble - France 38).
#
# SLIS : Serveur de communications Linux Pour l'Internet Scolaire.
# Copyright (C) 1999 Bruno Bzeznik
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program (For example ./COPYING);
# if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
# Cambridge, MA 02139, USA.
#
# Please send all comments and bug reports by electronic mail to:
# Bruno Bzeznik <Bruno@ac-grenoble.fr>
# or to <slis@ac-grenoble.fr>
#
# Envoyez vos suggestions et reports de bugs par e-mail α
# Bruno Bzeznik <Bruno@ac-grenoble.fr>
# ou α <slis@ac-grenoble.fr>
. /home/hadmin/slis.conf
LOG="/var/log/pushsite.log"
LOG_WGET="/var/log/wget.log"
# Modification webmaster.
if [ -f $QUEUE/webmaster ]
then
WEBMASTER=`cat $QUEUE/webmaster`
export WEBMASTER
# Test if the SLIS is OK for that
if [ ! -f /bin/ftshell ]
then
ln -s /bin/false /bin/ftpshell
fi
ftpshell=`grep ftpshell /etc/shells`
if [ "$ftpshell" = "" ]
then
echo "/bin/ftpshell" >> /etc/shells
fi
# Debut du script en perl modifiant /etc/smb.conf
/usr/bin/perl <<"EOF"
open (SMB,"/etc/smb.conf");
open (TMP,">/tmp/_smb.conf_");
$flag = 0;
while (<SMB>) {
if (/^.*\[web].*$/) {$flag=1}
if ($flag == 1) {
if (/^.*\[.*\].*$/ && !(/^.*\[web].*$/)) {$flag=0; print TMP $_;}
else {
if (/^.*valid user.*$/) {
print TMP " valid users = ",$ENV{WEBMASTER},"\n";
}
else {print TMP $_}
}
}
else {print TMP $_}
}
close SMB;
close TMP;
EOF
# Fin du script en perl modifiant /etc/smb.conf
mv -f /tmp/_smb.conf_ /etc/smb.conf
/etc/rc.d/init.d/smb restart
# Modification des droits d'acces au repertoire du site.
chown -R $WEBMASTER /home/httpd/html
chmod -R 755 /home/httpd/html
mv -f $QUEUE/webmaster $BASE/webmaster
/usr/local/sbin/permslis
# Modifications pour l'acces FTP et shell
# Les eventuels anciens webmaster deviennent utilisateurs normaux
grep "/home/httpd/html" /etc/passwd > /tmp/_passwd
if [ -s /tmp/_passwd ]
then
for i in `awk -F: '{print $1}' /tmp/_passwd`
do
usermod -d /home/$i -s /bin/false $i
done
fi
rm -rf /tmp/_passwd
# Le webmaster a son home dans /home/httpd/html et il a un shell specifique
usermod -d /home/httpd/html -s /bin/ftpshell $WEBMASTER
fi
# Replication.
if [ -f $QUEUE/webreplic ]
then
## REPLICATION DU SITE PUBLIC
#############################
# Configuration
if [ -f $QUEUE/pushsite.slis ]
then
mv -f $QUEUE/pushsite.slis $BASE/pushsite.slis
$SLIS_BINDIR/mkpushsiteconf
fi
# Lancement
if [ -f $QUEUE/pushsite.start ]
then
$SLIS_BINDIR/lance_pushsite&
rm -rf $QUEUE/pushsite.start
fi
# Abandon
if [ -f $QUEUE/pushsite.stop ]
then
date=`date`
echo "$date : ABANDON demande par l'administrateur SLIS." >> $LOG
killall pushsite
killall ftp
rm -rf $QUEUE/pushsite.stop
fi
# Purge du log
if [ -f $QUEUE/pushsite.purge ]
then
cp /dev/null $LOG
rm -rf $QUEUE/pushsite.purge
fi
## ASPIRATION DE SITES
#############################
# Configuration
if [ -f $QUEUE/wget.slis ]
then
mv -f $QUEUE/wget.slis $BASE/wget.slis
mv -f $QUEUE/wget-auto.slis $BASE/wget-auto.slis
$SLIS_BINDIR/mkwgetlauncher
fi
# Lancement
if [ -f $QUEUE/wget.start ]
then
$SLIS_BINDIR/launch_wget&
rm -rf $QUEUE/wget.start
fi
# Abandon
if [ -f $QUEUE/wget.stop ]
then
date=`date`
echo "$date : ABANDON demande par l'administrateur SLIS." >> $LOG_WGET
killall launch_wget
killall wget
WEBMASTER=`ls -ld /home/httpd/html |awk '{print $3}'`
chown -R $WEBMASTER /home/httpd/html/miroirs
rm -rf /var/lock/slis.wget
rm -rf $QUEUE/wget.stop
fi
# Purge du log
if [ -f $QUEUE/wget.purge ]
then
cp /dev/null $LOG_WGET
rm -rf $QUEUE/wget.purge
fi
# Suppression d'un site aspire
if [ -f $QUEUE/wget.del ]
then
for i in `cat $QUEUE/wget.del`
do
if [ $i != "" ]
then
R=$RANDOM
rm -rf /home/httpd/html/miroirs/$i
grep -v $i /home/httpd/html/miroirs/.miroirs > /tmp/.miroirs.$R
mv -f /tmp/.miroirs.$R /home/httpd/html/miroirs/.miroirs
fi
done
rm -rf $QUEUE/wget.del
fi
# Suppression du drapeau
rm -rf $QUEUE/webreplic
fi