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-post
< prev
next >
Wrap
Text File
|
2012-10-28
|
9KB
|
253 lines
#!/bin/bash
# slis_update-common-post
# Common updates, started after version updates
### VARIABLES ###
UPDDIR=/home/hadmin/updates
LOGTAG="slis_update[$$]"
grep HOSTNAME /etc/sysconfig/network > /tmp/hostname
. /tmp/hostname
rm -rf /tmp/hostname
WEBMASTER=`ls -ld /home/httpd/html |awk '{print $3}'`
. /home/hadmin/slis.conf 2>/dev/null
. /usr/local/lib/slis-sys.inc.bash 2>/dev/null
load_config 2>/dev/null
##################
# Locking
if [ -e /var/lock/slis_upd ]
then
logger -t "$LOGTAG" "Lock found. Update already started."
exit
fi
touch /var/lock/slis_upd
sleep 1
logger -t "$LOGTAG" "Script Common-Post started."
##############################
############################################################################
### Update C-16 - 01/10/2001
# New update script with a better locking and "freeze" checking
# Obsoletes :
############################################################################
if [ ! \( -e $UPDDIR/C-16 \) ]
then
# Telechargement du tar
cd /tmp
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/upd-C-16.tgz .
cd /
tar zxf /tmp/upd-C-16.tgz
RC1=$?
/usr/local/sbin/permslis
# Cron modification
R=$RANDOM
crontab -l > /tmp/cron.$R
COUNT=`wc -l /tmp/cron.$R|awk '{print $1}'`
tail -`expr $COUNT - 3` /tmp/cron.$R|sed "s;slis_update\.cron;slis_update;" > /tmp/cron.new.$R
rm -f /tmp/cron.$R
if [ "`wc -l /tmp/cron.new.$R|awk '{print $1}'`" = "`expr $COUNT - 3`" ]
then
crontab /tmp/cron.new.$R
RC2=$?
rm -f /tmp/cron.new.$R
fi
# Verification et fin de la MAJ
if [ $RC1 = 0 -a $RC2 = 0 ]
then
touch $UPDDIR/C-16
mv /usr/local/sbin/slis_update.cron /usr/local/sbin/slis_update.cron.obsolete
logger -t "$LOGTAG" "Update C-16 done."
else
logger -t "$LOGTAG" "Update C-16 FAILED."
fi
fi
###
############################################################################
### Update C-16b - 03/10/2001
# Fixes a little bug of C16 (obsolete use of slis_update.cron in rc.local)
# Obsoletes :
############################################################################
if [ ! \( -e $UPDDIR/C-16b \) ]
then
R=$RANDOM
sed "s;slis_update\.cron;slis_update;" /etc/rc.d/rc.local > /tmp/rc.local.$R
cp -f /etc/rc.d/rc.local /etc/rc.d/rc.local.C-16b
mv -f /tmp/rc.local.$R /etc/rc.d/rc.local
chmod 755 /etc/rc.d/rc.local
touch $UPDDIR/C-16b
logger -t "$LOGTAG" "Update C-16b done."
fi
###
############################################################################
### Update CP-1
# Activates Magic Quotes into /etc/php.ini
# Obsoletes :
############################################################################
if [ ! \( -e $UPDDIR/CP-1 \) ]
then
cp -f /etc/php.ini /etc/php.ini.upd-CP-1
sed "s/magic_quotes_gpc.*=.*Off/magic_quotes_gpc = On/" /etc/php.ini.upd-CP-1 > /etc/php.ini
chown nobody.nobody /etc/php.ini
killall -HUP httpd
touch $UPDDIR/CP-1
logger -t "$LOGTAG" "Update CP-1 done."
fi
###
############################################################################
### Update CP-2
# Remove masquerade script from rc.local (it erases rules created into
# post-mkfilter-script)
# Obsoletes : YES (Slis core update 3.2-19 do the correct job)
############################################################################
#if [ ! \( -e $UPDDIR/CP-2 \) ]
#then
#
# perl -pi -e "s;/usr/local/sbin/masquerade;;" /etc/rc.d/rc.local
#
# touch $UPDDIR/CP-2
# logger -t "$LOGTAG" "Update CP-2 done."
#fi
###
############################################################################
### Update BASES SQUIDGUARD - Every day
# ATTENTION: Let this update always at the very end of the update script.
# Please, mirror:
# ftp://ftp.univ-tlse1.fr/pub/reseau/cache/squidguard_contrib
# into your rsync module and maintain academie.tar.gz
############################################################################
if [ -e /usr/local/squid/squidGuard/db ]
then
logger -t "$LOGTAG" "UPDATE URL BLACKLISTS: start"
# Test if we have enough memory and cpu to make the .db files
declare -i MEM=`free -m|grep "Mem:"|awk '{print $2}'`
declare -i BOGOMIPS=`grep bogomips /proc/cpuinfo |awk '{print $3}'|cut -d. -f1|head -1`
if [ $MEM -lt 127 -o $BOGOMIPS -lt 1500 ]
then
LOWRESSOURCES=1
logger -t "$LOGTAG" "Low ressources detected, will use the precompiled version of the adult blacklist..."
else
LOWRESSOURCES=0
fi
# Check the version of the files to download
VER=`cat /etc/version_slis_num`
if [ "$VER" != "3.1" -a "$VER" != "3.2" ]
then
VER=2.x_3.0
else
VER=3.1
fi
# Download the bases
cd /usr/local/squid/squidGuard/db
if [ "$LOWRESSOURCES" = "1" ]
then
rm -f adult.tar.gz
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/adult-precompiled-$VER.tar.bz2 .
else
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/adult.tar.gz .
fi
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/warez.tar.gz .
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/forums.tar.gz .
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/publicite.tar.gz .
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/publicite.tar.gz .
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/academie.tar.gz .
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/tricheur.tar.gz .
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/agressif.tar.gz .
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/drogue.tar.gz .
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/redirector.tar.gz .
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/strict_redirector.tar.gz .
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/radio.tar.gz .
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/mobile-phone.tar.gz .
rsync rsync://$RSYNC_HOST/$RSYNC_MODULE/webmail.tar.gz .
logger -t "$LOGTAG" "Blacklists installation. PLEASE WAIT..."
# Extract the bases
if [ "$LOWRESSOURCES" = "1" ]
then
rm -f adult/domains
rm -f adult/urls
tar jxf adult-precompiled-$VER.tar.bz2
else
tar zxf adult.tar.gz
fi
tar zxf warez.tar.gz
tar zxf forums.tar.gz
tar zxf publicite.tar.gz
tar zxf academie.tar.gz
tar zxf tricheur.tar.gz
tar zxf agressif.tar.gz
tar zxf drogue.tar.gz
tar zxf redirector.tar.gz
tar zxf strict_redirector.tar.gz
tar zxf radio.tar.gz
tar zxf mobile-phone.tar.gz
tar zxf webmail.tar.gz
/usr/local/sbin/permslis
# Make the .db files
if [ "$LOWRESSOURCES" = "0" ]
then
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/adult/domains
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/adult/urls
fi
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/warez/domains
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/warez/urls
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/forums/domains
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/forums/urls
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/publicite/domains
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/publicite/urls
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/academie/domains
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/academie/urls
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/agressif/domains
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/agressif/urls
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/drogue/domains
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/drogue/urls
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/tricheur/domains
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/tricheur/urls
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/redirector/domains
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/redirector/urls
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/strict_redirector/domains
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/strict_redirector/urls
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/radio/domains
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/mobile-phone/domains
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/mobile-phone/urls
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/webmail/domains
/usr/local/squid/bin/squidGuard -C /usr/local/squid/squidGuard/db/webmail/urls
/usr/local/sbin/permslis
logger -t "$LOGTAG" "Restarting proxy."
killall -HUP squid
logger -t "$LOGTAG" "UPDATE URL BLACKLISTS: end"
fi
###
##############################
logger -t "$LOGTAG" "Script Common-Post ended."
/bin/rm -rf /var/lock/slis_upd