[Linux-Biella] scripting, ovvero: oggi passa poco
LeOS
linux@bilug.linux.it
Fri, 29 Aug 2003 11:02:16 +0200
a voi il compito di capire ke e' :)
#!/bin/bash
#file: /opt/bin/updaterh
cp /var/log/up2date /var/log/up2date.old
echo -n "Beginning update: " >> /var/log/updaterh.log
date >> /var/log/updaterh.log
/usr/sbin/up2date -u --force
echo -n "Finishing update: " >> /var/log/updaterh.log
date >> /var/log/updaterh.log
echo "---" >> /var/log/updaterh.log
# Intercepting kernel updates ;)
stringa=$(diff /var/log/up2date /var/log/up2date.old |grep kernel)
lung=${#stringa}
echo "Stringa: $stringa"
echo "Lunghezza: $lung"
if [ $lung -gt 0 ]; then
echo -n "Need rebooooot:" >> /var/log/reboot.log
date >> /var/log/reboot.log
echo "---" >> /var/log/reboot.log
touch /tmp/needreboot
fi
#fine file
#!/bin/bash
#file: /opt/bin/needreboot
if [ -e /tmp/needreboot ]; then
rm /tmp/needreboot
/sbin/reboot
fi
#fine file
crontab:
00 22 * * * /opt/bin/updaterh 1> /dev/null
00 01 * * fri /opt/bin/needreboot 1> /dev/null
--
Linux Registered User #135079
public gpg key: gpg --keyserver pgp.mit.edu --recv-key 2ED92C69