#!/bin/sh
# Run this weekly usually on Fridays or Saturdays to get a week's worth of data
#
if [ "$#" -lt "1" ]
then echo 'Usage: doit fetch|make|both';
     echo '            fetch gets the web pages'
     echo '            make makes the slice file'
     echo '            both does both'
     exit 1
fi
cmd=$1

set `date`
today=$1
oday="$3$2$6"

case $today in
  Fri) daylist='All 2-8' ;;
  Sat) daylist='All 1-7' ;;
  Sun) daylist='All 0-6' ;;
  Mon) daylist='All 0-5' ;;
  Tue) daylist='All 0-4' ;;
  Wed) daylist='All 0-3' ;;
  Thu) daylist='All 0-2' ;;
esac

if [ "$cmd" = "fetch" -o "$cmd" = "both" ]
then echo 'About to fetch and save 1 week of data from Sofcom'
     ./fetch_one -w -n -o /dev/null $daylist
     echo -n 'Time to edit the programs file for any new programs ->'
     read answer
     vi Files/programs
     echo ' '
     echo ' '
     if [ "$cmd" = "both" ]
     then echo -n 'Press enter now to generate the new slice, or ^C to exit ->'
          read answer
     fi
fi

if [ "$cmd" = "make" -o "$cmd" = "both" ]
then echo 'Now generating the new slice file'
     ./fetch_one -r -o output.slice $daylist
fi
