#!/bin/bash # Script to be put in cron, to download scenery files # written by: BP{k} # # Changes: # - fixed a parsing bug which prevented getting all the # filenames from the index.html # Get the directory listing first MIRROR="ftp://ftp.flightgear.org/pub/fgfs/Scenery-0.9.10" SOURCE="scenery-names" LISTING="index.html" #get a list of files from the mirror if [ ! -f $SOURCE ]; then if [ ! -f $LISTING ]; then wget $MIRROR/ fi cat $LISTING | grep tgz | awk -F . '{ print $6 "." $7 }' | awk -F \> '{ print $2 }' | awk -F \< '{ print $1 }' > $SOURCE rm $LISTING fi # How many files are we looking at ? LENGTH=`wc -l $SOURCE | awk '{ print $1 }'` COUNT=5 # Lets download them until [ $COUNT -ge $LENGTH ]; do DGET=`cat $SOURCE | head -$COUNT | tail -5` BATCH=($DGET) NUM=0 while [ $NUM -ne ${#BATCH[*]} ]; do wget -c $MIRROR/${BATCH[$NUM]} let NUM=$NUM+1 done # This will update the script so that the next time its started the # value of count will be 5 higher CNTVALUE=$COUNT let NEWCNT=$COUNT+5 sed -e s/COUNT\=$CNTVALUE/COUNT\=$NEWCNT/g $0 > $0.new chmod 744 $0.new mv $0.new $0 exit done echo "All files have been downloaded. Nothing more to do" echo "Enjoy the world in FlightGear!" exit