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-3.1
< prev
next >
Wrap
Text File
|
2006-04-03
|
10KB
|
276 lines
#!/bin/bash
# slis_update-3.1
# Updates for SLIS 3.1
# 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>
#
### VARIABLES ###
LOGTAG="slis_update[$$]"
UPDDIR="/home/hadmin/updates"
. /usr/local/lib/slis-sys.inc.bash
load_config
##################
# 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 Version 3.1 started."
# Spring cleaning
if [ ! \( -e $UPDDIR/clean01 \) ]
then
logger -t "$LOGTAG" "Cleaning the cache"
rm -f /var/cache/apt/archives/kernel*2.4.22-1.2166*
rm -f /var/cache/apt/archives/kernel*2.4.22-1.2174*
rm -f /var/cache/apt/archives/perl*5.8.3-10*
touch $UPDDIR/clean01
logger -t "$LOGTAG" "Cleaning done."
fi
# Installation of Fedora Legacy Public GPG key
if [ ! \( -e $UPDDIR/FLkey \) ]
then
logger -t "$LOGTAG" "Installing FL GPG Key"
cat > /etc/FEDORA-LEGACY-GPG-KEY << EOF
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.0.7 (GNU/Linux)
mQGiBEALkQkRBACCBCp/a5rsqy2Q0NW/2OMkYtsb3k5M6dsQYoHDLiZK4VG1j+Bf
2zzp+HJiUnLFp/l7mROuRioU9/UHpEYFIVunBYXeZf84OxB+mruh9UZtYn3oVXtH
oaMI7hIFirTZ5eEY7zrfvTbvZ2Sm5cE3F2G5sWVOfxhl5opinuWN4xtSwwCggooh
LqarkF4KN6D8xoyjrhLaxiMD/Az7RE6oH0Vwl9dX7YmccymDEesT5Ql6Q5FvfkuZ
F5ZaQwaBO2ko2hMMh2AdCxoYAZPjWqC5r6Wy9P8hMfh+A0S4zon2DE/r0d4vLEY2
HoptwtElq6gpltydx+/vXhZWkwCO//Kz9wXgZr496KtGXmEKYtdlVScBW6OvdyyD
18zeA/9RuY59C7uxxe6cu7amqjP52xx5rHGkdJD5E8o3rmjdsr9tJ3FcjtIV0DV2
BkfLIMnsp2gd972n7JBzlA9LJ+JTtMzvf9WdrErpRz1VeI1jHe4/hNGe3hd6xJIE
rxj5FH+LwTj3vfErZdKsWOuudNkz1N4AwZr/k05gV3bi7j8RCLRIRmVkb3JhIExl
Z2FjeSAoaHR0cDovL3d3dy5mZWRvcmFsZWdhY3kub3JnKSA8c2Vjbm90aWNlQGZl
ZG9yYWxlZ2FjeS5vcmc+iFkEExECABkFAkALkQkECwcDAgMVAgMDFgIBAh4BAheA
AAoJEBCMRRJzEAL686wAn3bA5dioMd0UDpUaES9TglLDpONbAJ467XWdHHwhxuHz
oxWc3q7rWPBinLkCDQRAC5EuEAgAsPAVcrvrKB1A/hxoM61KEgaLB9GnGUOgoaV6
I58stO3sxaxj3bblrpIJjo02BA49xrtL8kpqjKveABThVC1yiSYfySmXKHlO09cv
A+qj+QSxieRciFKc50F1+j8q5Hqcigxzwhr4sJt5IhAx6HIwar5uxNNBgE98JN42
GthUH39G+alRmzVd+3gQCLFroJSzHtFX7IlwHM33owAZwIVGlUhlBTHdbsvGf0xG
mPYkI+JAUXpTTsnP7kR0/Ktm3zAHBEMw19eqQ5MSwVo28cA+jq2sLrL5DiE5quCd
tB/RVnUUdbfN/o8sN6yxssNB6ZOB61l0K8bvm+9Qgstn/EQFSwADBggAmmFJueD1
iXehZsRtaH+qZw7z6Q6jUPxDTiuVPhLkUux3wOSWMOp6S+ZYliCaw32TBKgE2SwT
NnvTJYsuGLf3ECxOxMmu2McDHYZM82zRV4PRBMKFfiOa67/x5lhZgEkqf9TO+wk5
M67GYbjZoyBaYEiE+eWD2cdema3n3zXzy+q2UEkHkzHx6ME9dRrgND3EW2hC9GJ6
7wY9h+BlUR6Am4o0/ZLZJ2QEvyVnlI3/zZo9L6h8waZKI4l16nuDr/O8z2UOYc/X
OMwBJCVwvbB2Z/f91dhy2EVWJZyyZBCG/FMXXDchxKwJOOQgrVbxWGDIMSdyHLUL
2FuWnC/vdKc7wYhGBBgRAgAGBQJAC5EuAAoJEBCMRRJzEAL6wkcAnAlIrH0JuGjL
T17HoheG/iUbj4Z4AJ9b/7OPGgNglwrLQJfihyPzManKYw==
=wmoy
-----END PGP PUBLIC KEY BLOCK-----
EOF
rpm --import /etc/FEDORA-LEGACY-GPG-KEY
touch $UPDDIR/FLkey
logger -t "$LOGTAG" "FL GPG Key installed"
fi
# APT updates
logger -t "$LOGTAG" "Starting apt-get update..."
logger -t "$LOGTAG" "=== PLEASE WAIT. DO NOT USE SLIS WHILE UPDATING ==="
apt-get -q2 update
if [ $? != 0 ]
then
logger -t "$LOGTAG" "ERROR: apt-get update failed!"
else
# SLIS updates
logger -t "$LOGTAG" "Starting apt-get install slis-up2date..."
apt-get -q2 install slis-up2date > /tmp/$$.apt
if [ $? != 0 ]
then
logger -t "$LOGTAG" "ERROR: apt-get install slis-up2date failed!"
else
LOGSTRING=`grep -v Executing /tmp/$$.apt|grep -v Preparing|grep -v Checking|awk '{print $1}'`
logger -t "$LOGTAG" "Installed updates: $LOGSTRING"
fi
/bin/rm -f /tmp/$$.apt
# Official updates
logger -t "$LOGTAG" "Starting apt-get upgrade (maybe long)..."
apt-get -q2 upgrade > /tmp/$$.apt
if [ $? != 0 ]
then
logger -t "$LOGTAG" "ERROR: apt-get upgrade failed!"
else
LOGSTRING=`grep -v Executing /tmp/$$.apt|grep -v Preparing|grep -v Checking|awk '{print $1}'`
logger -t "$LOGTAG" "Installed updates: $LOGSTRING"
fi
# Kernel update (only the night)
declare -i HOUR
HOUR=`date +%k`
if [ $HOUR -lt 6 ]
then
logger -t "$LOGTAG" "Well, it's the night, let's check for a kernel update..."
logger -t "$LOGTAG" "Removing old kernel(s)..."
#last_kernel=`rpm -q kernel |sort|tail -1|grep -v "is not installed" 2>/dev/null`
#last_kernel=`rpm --last -q kernel |grep -v "is not installed"|head -1|awk '{print $1}' 2>/dev/null`
last_kernel=`rpm -q --qf "%{BUILDTIME}:%{NAME}-%{VERSION}-%{RELEASE}\n" kernel|grep -v "is not installed"|sort|tail -1|cut -f2 -d:`
#last_smpkernel=`rpm -q kernel-smp |sort|tail -1|grep -v "is not installed" 2>/dev/null`
#last_smpkernel=`rpm --last -q kernel-smp |grep -v "is not installed"|head -1|awk '{print $1}' 2>/dev/null`
last_smpkernel=`rpm -q --qf "%{BUILDTIME}:%{NAME}-%{VERSION}-%{RELEASE}\n" kernel-smp|grep -v "is not installed"|sort|tail -1|cut -f2 -d:`
if [ "$last_kernel" != "" ]
then
for i in `rpm -q kernel`
do
if [ "$i" != "$last_kernel" ]
then
if [ "`echo $i|sed \"s/^kernel//\"`" = "`uname -r`" ]
then
logger -t "$LOGTAG" "Warning: not removing old kernel $i as it is the running one"
else
rpm -e $i
logger -t "$LOGTAG" "Removed $i"
fi
fi
done
fi
if [ "$last_smpkernel" != "" ]
then
for i in `rpm -q kernel-smp`
do
if [ "$i" != "$last_smpkernel" ]
then
if [ "`echo $i|sed \"s/^kernel-smp-//\"`smp" = "`uname -r`" ]
then
logger -t "$LOGTAG" "Warning: not removing old kernel $i as it is the running one"
else
rpm -e $i
logger -t "$LOGTAG" "Removed $i"
fi
fi
done
fi
apt-get -q2 -o RPM::Upgrade-Kernel="true" upgrade > /tmp/$$.apt
if [ $? != 0 ]
then
logger -t "$LOGTAG" "ERROR: apt-get upgrade for the kernel failed!"
else
LOGSTRING=`grep -v Executing /tmp/$$.apt|grep -v Preparing|grep -v Checking|awk '{print $1}'`
if [ "$LOGSTRING" != "" ]
then
logger -t "$LOGTAG" "KERNEL UPDATED. REBOOTING NOW..."
if [ "`uname -v |grep SMP`" != "" ]
then
SMP="smp"
else
SMP=""
fi
KERNEL_STR=`/bin/ls -r --sort=time /boot/vmlinuz-*$SMP |tail -1`
/sbin/grubby --set-default="$KERNEL_STR"
/sbin/reboot
killall slis_update
killall slis_update.dev
else
logger -t "$LOGTAG" "Kernel seems up to date. No change."
fi
fi
fi
# Cache cleaning
logger -t "$LOGTAG" "Cleaning the APT cache..."
# Not running "apt-get -q2 clean" because we want the partial downloaded
# files to been kept.
/bin/rm -f /var/cache/apt/archives/*rpm
logger -t "$LOGTAG" "APT updates finished."
/bin/rm -f /tmp/$$.apt
fi
# The first Fedora Legacy kernel update was not updating the default
# grub image
if [ ! \( -e $UPDDIR/flkbug01 \) -a $HOUR -lt 6 ]
then
if [ "`grubby --default-kernel`" = "/boot/vmlinuz-2.4.22-1.2199.nptlsmp" \
-o "`grubby --default-kernel`" = "/boot/vmlinuz-2.4.22-1.2199.nptl" ]
then
logger -t "$LOGTAG" "Default kernel was not up2date. Rebooting with the good one..."
if [ "`uname -v |grep SMP`" != "" ]
then
SMP="smp"
else
SMP=""
fi
KERNEL_STR=`/bin/ls -r --sort=time /boot/vmlinuz-*$SMP |tail -1`
/sbin/grubby --set-default="$KERNEL_STR"
/sbin/reboot
fi
touch $UPDDIR/flkbug01
fi
# Reboot if the default kernel is not the running one
# It's still a consequence of the first FL kernel update
# that was a nightmare...
if [ ! \( -e $UPDDIR/flkbug02 \) ]
then
if [ "`grubby --default-kernel |sed \"s,/boot/vmlinuz-,,\"`" != "`uname -r`" ]
then
logger -t "$LOGTAG" "Running kernel is not the default one, rebooting..."
/sbin/reboot
fi
touch $UPDDIR/flkbug02
fi
# courier-imap installation
if [ ! \( -e $UPDDIR/courier-imap \) ]
then
logger -t "$LOGTAG" "Installing courier-imap..."
apt-get -q2 install courier-imap > /tmp/$$.courier.apt
if [ $? != 0 ]
then
logger -t "$LOGTAG" "ERROR: apt-get install courier-imap failed!"
else
logger -t "$LOGTAG" "Courier-imap installed."
touch $UPDDIR/courier-imap
fi
fi
##############################
logger -t "$LOGTAG" "Script Version 3.1 ended."
/bin/rm -rf /var/lock/slis_upd