#!/bin/sh
#
# Script to make a Bacula "rescue" disk
#
export LANG=C

# Print Usage message
usage () {
   cat <<END_OF_DATA
Usage: make_rescue_disk
  -h, --help             print this message
  --make-static-bacula   make static File daemon and add to diskette
  --copy-static-bacula   copy static File daemon to diskette
  --copy-etc-files       copy files in etc list to diskette
END_OF_DATA
}

# defaults
make_bacula=no
copy_bacula=no
copy_etc=yes

#
# Process command line options
#
for option in "$@" ; do
   case "$option" in
   -h | --help)
      usage
      exit 0
      ;;
   --make-static-bacula)
      make_bacula=yes
      copy_bacula=yes
      ;;
   --copy-static-bacula)
      copy_bacula=yes
      ;;
   --copy-etc-files)
      copy_etc=yes
      ;;
   *)
      echo "Unknown option specified: $option"
      usage
      exit 1
      ;;
   esac
done

if [ x$make_bacula = "xyes" ] ; then
   ./make_static_bacula
fi

if [ x$copy_etc = "xyes" ] ; then
   echo "Tarring /etc files to current directory"
   tar --create --gzip --file ./etc.gz --files-from backup.etc.list
fi
