On Sat, 28 Oct 2000, stephen wrote:
> On Sat, Oct 28, 2000 at 10:36:44AM +0100, stephen wrote:
<...>
> btinternet in their infinite something, drop the line every 2 hrs
> and it's dynamic ip, not a problem when i use download 4 x
> netscape downloads need stopping and restarting.. pain
> what happens with rsync connections, have i really got to wake up
> every 2 hrs
> i don't suppose anyone has a suitable script for adaption ?
I run this from my crontab every 2 hours 20 minutes.
##########################################################################
#!/bin/bash
# /usr/local/bin/rsync-iso
echo ==============================================================================
echo rsync-iso - this script will download the latest Mandrake iso.
echo
#
# Variables
#
NORWAY="sunsite.uio.no::Mandrake/iso/"
REMOTEDIR=$NORWAY
LOCALPARTITION='/mnt/downloads'
LOCALDIR='/mnt/downloads/Mandrake/iso/'
MYISP='greatXscape'
DIALUPDELAY='20s'
ISTATUS=`netstat -i|grep ppp0`
# TIMEOUT This option allows you to set a maximum IO timeout in seconds. If no
# data is transferred for the specified time then rsync will exit. The default
# is 0, which means no timeout.
TIMEOUT=7100
H=$[$TIMEOUT/3600]
S=$[$TIMEOUT-$[$H*3600]]
M=$[$S/60]
S=$[$S-$[$M*60]]
# If ppp already running, quit.
if [ "$ISTATUS" != "" ] ; then
echo "ppp already running - I'm leaving it alone! - Goodbye."
exit
fi
echo "Connecting to $MYISP ..."
echo
/sbin/ifup ppp0
# Allow a delay before connect.
while [ "$ISTATUS" == "" ] ; do
sleep 1
ISTATUS=`netstat -i|grep ppp0`
done
# I like this monitor.
echo "Spawning: GKrellM stacked system monitors ..."
echo
[ "$DISPLAY" = ":0" ] && /usr/X11R6/bin/gkrellm &
echo "Ready to start the download"
echo
if [ $H = 0 ] ; then
echo "After $M minutes, rsync will stop if data transfer is interrupted."
elif [ $H = 1 ] ; then
echo "After 1 hour and $M minutes, rsync will stop if data transfer is
interrupted."
else
echo "After $H hours and $M minutes, rsync will stop if data transfer is
interrupted."
fi
# Get the start time
START=`date +%s`
# Get directory size at start
T1=`du -sm $LOCALDIR|gawk '{print $1}'`
# This is the busy stuff ...
rsync -rltvP --stats --timeout=$TIMEOUT \
$REMOTEDIR $LOCALDIR
# Get finish time ...
FIN=`date +%s`
ELAPSED=$[$FIN-$START]
H=$[$ELAPSED/3600]
S=$[$ELAPSED-$[$H*3600]]
M=$[$S/60]
S=$[$S-$[$M*60]]
# ... and report how long it ran at end of script.
# Get directory size at finish and report download size (at end of script).
T2=`du -sm $LOCALDIR|gawk '{print $1}'`
F=`df | grep $LOCALPARTITION|gawk '{print $5}'`
T=$(($T2-$T1))
# All done!
echo "quitting ppp ..."
/sbin/ifdown ppp0
echo
echo "terminating GKrellM ..."
echo
killall gkrellm &> /dev/null
# Report how long it ran.
echo
if (( $H == 0 )) ; then
echo "rsync was running for $M minutes until `date`."
elif (( $H == 1 )) ; then
echo "rsync was running for 1 hour and $M minutes until `date`."
else
echo "rsync was running for $H hours and $M minutes until `date`."
fi
# Report download size.
if (( $T != 0 )); then
if (( $T >= 0 )) ; then
echo
echo "After rsync, $LOCALPARTITION is now $T MB bigger at $T2 MB ( $F
used )."
echo
else
echo
echo "After rsync, $LOCALPARTITION is now $((-$T)) MB smaller at $T2
MB ( $F used )."
echo
fi
fi
exit 0
--
------------------------------------------------------
Peter Ruskin <[EMAIL PROTECTED]>
Wrexham, UK KDE - the professionals' choice
------------------------------------------------------