Re: Auto dist-upgrade script

2002-09-07 Thread Carlos Sousa

On Thu, 5 Sep 2002 23:53:04 -0400 ThanhVu Nguyen [EMAIL PROTECTED] wrote:

 Hi, I've heard people can write some scripts and put it in a cron job
 that do a dist-upgrade on their system then send what've been upgraded
 to their emails.  Can someone share how they did it ?  thanks

There's a debian package to do this, but I had already rolled my own
when I came across it. I have in /etc/cron.d/apt-upgrade the following
entry:
-8-8-8-8-8-8-8-8-8-
UPGTMP=/var/tmp/.outf.apt-upgrade

30 7,15,23   * * *   root   /usr/local/sbin/apt-upgrade | tee $UPGTMP
-8-8-8-8-8-8-8-8-8-
which tries to download upgraded packages and send the results to me by
mail, as well as storing them in a log file.

The /usr/local/sbin/apt-upgrade script checks to see if it is already
running, takes access failures into account by retrying a certain number
of times, and downloads all the updated packages (the installation
of the packages should *never* be done automatically).

It goes like this:
-8-8-8-8-8-8-8-8-8-
#!/bin/bash

BASE=/var/tmp
LOCK=$BASE/.lock.apt-upgrade
DONE=$BASE/.done.apt-upgrade

MAXTRIES=5   # retry limit
SLEEPSECS=300# seconds to sleep between retries

SEP=

echo $SEP ; echo $0 ; echo $SEP ; date ; echo $SEP ; echo

if [ -e $LOCK ] ; then
   echo
   echo ERROR: already running ($LOCK exists, process `cat $LOCK`).
   echo Exiting...
   echo
   exit
fi

TRIES=1

echo -n $$  $LOCK

while ! apt-get update ; do
   echo 
   if [ $TRIES -eq $MAXTRIES ] ; then
  echo  Try $TRIES: there were errors. Try limit reached, giving up.
  echo 
  break
   else
  echo  Try $TRIES: there were errors. Sleeping for $SLEEPSECS s...
  echo 
  sleep $SLEEPSECS ; TRIES=$(($TRIES + 1))
   fi
done

echo ; echo $SEP ; date ; echo $SEP ; echo

TRIES=1

while ! apt-get -d -y -u dist-upgrade ; do
   echo 
   if [ $TRIES -eq $MAXTRIES ] ; then
  echo  Try $TRIES: there were errors. Try limit reached, giving up.
  echo 
  break
   else
  echo  Try $TRIES: there were errors. Sleeping for $SLEEPSECS s...
  echo 
  sleep $SLEEPSECS ; TRIES=$(($TRIES + 1))
   fi
done

echo  ; echo  Done after $TRIES tries. ; echo 

echo ; echo $SEP ; date ; echo $SEP ; echo

rm -f ${DONE}*
mv $LOCK ${DONE}.$(date +%Y-%m-%d-%H:%M)
-8-8-8-8-8-8-8-8-8-

-- 
Carlos Sousa
http://vbc.dyndns.org/


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: Auto dist-upgrade script

2002-09-06 Thread Scott Henson

On Thu, 2002-09-05 at 23:53, ThanhVu Nguyen wrote:
 Hi, I've heard people can write some scripts and put it in a cron job
 that do a dist-upgrade on their system then send what've been upgraded
 to their emails.  Can someone share how they did it ?  thanks

This is my crontab to do nightly mantinence on my system(backups to be
added as soon as I get my new server up and running :-D)

 # use /bin/sh to run commands, no matter what /etc/passwd says
 SHELL=/bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/bin/X11:/usr/local/sbin:/usr/local/bin
 # mail any output to `admin'
 [EMAIL PROTECTED]
 30 4  * * *   dselect update  apt-get dist-upgrade -ydu 
apt-history; ntpdate ns1.yourISP.com


-- 


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Auto dist-upgrade script

2002-09-05 Thread ThanhVu Nguyen

Hi, I've heard people can write some scripts and put it in a cron job
that do a dist-upgrade on their system then send what've been upgraded
to their emails.  Can someone share how they did it ?  thanks


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: Auto dist-upgrade script

2002-09-05 Thread Pierre THIERRY

 Can someone share how they did it ? 

$ man crontab apt-get

 thanks

It was a pleasure...

le Moine Fou
-- 
mailto:[EMAIL PROTECTED]
OpenPGP 0xD9D50D8A



msg00969/pgp0.pgp
Description: PGP signature