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_4.1_rsync
/
lcslis_dom0_update-common-pre
< prev
next >
Wrap
Text File
|
2009-05-24
|
3KB
|
121 lines
#!/bin/bash
# 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) 1998-2003 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>
#
# Contact: Olivier.LeCam@crdp.ac-versailles.fr
#
# Comments:
# Downloaded via rsync and executed by SLIS during
# the 'slis_update' process
# Started before version updates
#
# Updates:
# olecam: Jan 9, 2006: script ported to SLIS v4
#
# Variables
#
LOGTAG="lcslis_dom0_update-common-pre[$$]"
LOCKFILE="/var/lock/lcslis_dom0_update-common-pre"
SCRIPT_STATUS_MSG="Script 'lcslis_dom0_update-common-pre'"
UPDDIR="/etc/slis/updates"
write_to_log()
{
/usr/bin/logger -t "$LOGTAG" $*
}
send_to_slismaster()
{
echo "$*" | mail "$SLISMASTER" -s "`hostname` : Update: $LOGTAG"
}
exit_this_update()
{
write_to_log $*
send_to_slismaster $*
write_to_log "$SCRIPT_STATUS_MSG: failed."
exit 1
}
#
# Locking
#
if [ -e $LOCKFILE ]; then
# Then if the lock is older than 10 days, remove the lockfile and lock again.
LOCKFILE_OLD=`find $LOCKFILE -nowarn -ctime +10 -print`
if [ "$LOCKFILE_OLD" != "" ]; then
write_to_log "Info: Very old lock found (more than 10 days), removing it."
rm -f $LOCKFILE
else
write_to_log "Lock found. Update already started."
exit
fi
fi
touch $LOCKFILE
sleep 1
[ -d $UPDDIR ] || /bin/mkdir -p $UPDDIR
write_to_log "$SCRIPT_STATUS_MSG: started."
##############################
#
# Ensure that the host use apt-cacher from slis
#
if [ ! -f /etc/apt/apt.conf ] || [ "`grep 'http://slis:3142/apt-cacher/' /etc/apt/apt.conf`" == "" ]; then
touch /etc/apt/apt.conf
echo 'Acquire::http::Proxy "http://slis:3142/apt-cacher/";' >> /etc/apt/apt.conf
fi
#
# Ensure that 'at' is installed
#
if [ ! -f /usr/bin/at ]; then
write_to_log "INFO: installing needed packages 'at'"
APT_RESULT=`apt-get -qq update 2>&1`
if [ $? != 0 ]; then
write_to_log "ERROR: apt-get update failed. See report below:"
write_to_log "`echo -n "$APT_RESULT"`"
else
export DEBIAN_FRONTEND=noninteractive
apt-get --force-yes -y -qq install at | logger -t "$LOGTAG"
fi
fi
##############################
write_to_log "$SCRIPT_STATUS_MSG: successed."
rm -f $LOCKFILE