Syncvar

syncvar

 * 1) !/bin/sh
 * 2) Copyright (c) 2007  Matt Simerson
 * 3) All rights reserved.
 * 4) NOTE: this script runs early in the startup process, before
 * 5) /usr is available. It requires that a statically compiled
 * 6) version of rsync is installed in /bin/rsync.
 * 1) /usr is available. It requires that a statically compiled
 * 2) version of rsync is installed in /bin/rsync.


 * 1) PROVIDE: syncvar
 * 2) REQUIRE: mountcritlocal var
 * 3) KEYWORD: shutdown    # added per tom mazzotta

. /etc/rc.subr

name="syncvar" rcvar=`set_rcvar` command="/bin/rsync" excludes="--exclude spool/ --exclude tmp/ --exclude empty/" syncvar_enable=${syncvar_enable-"NO"} syncvar_dir=${syncvar_dir-"/var.disk"}

start_cmd="syncvar_start" stop_cmd="syncvar_stop"

load_rc_config $name

required_dirs="${syncvar_dir}"

syncvar_start { echo "Syncing var from disk." $command -av $excludes $syncvar_dir/ /var/  # noisy! }
 * 1)       $command -a  $excludes $syncvar_dir/ /var/   # nice and quiet

syncvar_stop { echo "Syncing var to disk."

more_excludes="--exclude run/ --exclude entropy/ --exclude supervise/"

# remount our $syncvar_dir as r/w ( /sbin/mount -u -o rw $syncvar_dir  ||  # HD boot           /sbin/mount -u -o rw /  ||             # CF boot           ( echo "Failed to sync var to disk!" && exit 1 )       )

# just show us what it would do
 * 1)       $command -avn $excludes $more_excludes /var/ $syncvar_dir/

# do the deed $command -av $excludes $more_excludes /var/ $syncvar_dir/

# do it quietly }
 * 1)       $command -a $excludes $more_excludes /var/ $syncvar_dir/

run_rc_command "$1"