#!/bin/bash

# Name: mirror v1.5
# Date: 2 June 2004
#
# Description: This is a script to mirror the FTP sites I choose to keep
# on my server. It can mirror either a single site or all sites depending
# on the parameters given on the command line.
#
# Usage: mirror [redhat|fedora|all]

case $1 in 

	redhat)
		SITE="ftp.dulug.duke.edu"
		SOURCEPATH="redhat-ftp/redhat"
		LOCALPATH="/data/pub/redhat"
		;;
	
	fedora)
		SITE="mirror.linux.duke.edu"
		SOURCEPATH="fedora-linux-core"
		LOCALPATH="/data/pub/fedora/linux/core"
		;;
	
	all)
		/home/rpaiz/mirror/mirror redhat &
		/home/rpaiz/mirror/mirror fedora &
		exit 0
		;;
	
	*)
		echo "Invalid parameter; please try again."
		echo
		exit 1

esac

# Execute the mirroring process and create the output file.

rsync -avP --exclude-from=excluded-$1 --delete --delete-excluded \
      --max-delete=100 $SITE::$SOURCEPATH/ $LOCALPATH/ > report-$1.$(date +%F)

# Done.
exit 0
