#!/bin/sh
#
# This script should by called by cron to update the ff-databases
# for r/w filesystems.
#
# When called with an argument is just updates that database
#	i.e.: update root.ff
#
# LOOK AT THE END OF THE FILE!!!
#

FF=/var/spool/ff
BIN=/usr/local/bin
DB=""

[ $# = 1 ] && { DB=$1; shift; }

[ $# != 0 ] && { echo >&2 "usage: $0 [database]"; exit 1; }

UPDATE() {
    [ -n "$DB" -a "$DB" != "$1" ] && return 1

    FILE="$FF/$1";
    SEC="$2"
    EXP="$3"
    INO="$4"
    COM="$5"
    shift 5

    IFLG=""; [ $INO = "yes" ] && IFLG="-I"

    test -t 1 && echo -n "update $FILE: "

    if $BIN/mk_ff $IFLG -o$FILE.new -s"$SEC" -e"$EXP" -c"$COM" "$@"
    then
	mv $FILE.new $FILE
	test -t 1 && echo "done."
    else
	rm -f $FILE.new
	test -t 1 && echo "failed."
	echo >&2 "error updating $file"
    fi
}

#	database      sec exp ino comment		misc		dirs
#------------------------------------------------------------------------------
UPDATE	root.ff		2   4 yes "daniel-root-fs"	-i /var/tmp	/
UPDATE	dosc.ff		0   4  no "daniel-dosc-fs"			/dos
