#!/bin/sh
#---------------------------------------------------------------------------
# /etc/rc0.d/sarfile
# (c) copyright 2002 by Reiner Schroeppel <reiner@schroeppel.info>
# see instructions for the licensing terms and conditions
# last modified 2002-06-26
#----------------------------------------------------------------------------

/usr/local/bin/colecho "Start saving persistant files..." gn

. /etc/sarfile.cfg

idx=1
while [ $idx -le $SARFILE_N ]; do
  eval source='$SARFILE_FILE_'$idx
  if [ -f "$source" ]; then
    eval destination='$SARFILE_SAVETO_'$idx
    if [ ! -d "$destination" ]; then
      /usr/local/bin/colecho "  creating backup directory $destination/..." wh
      mkdir -p $destination
    fi
    /usr/local/bin/colecho "  copying $source to $destination/..." w
    cp $source $destination/
  else
    /usr/local/bin/colecho "  cannot find $source..." rd
  fi
  idx=`expr $idx + 1`
done

/usr/local/bin/colecho "Done saving persistant files..." gn
