#!/bin/bash
#
#	This script checks the state of all the files on the system
#	against its current configuration, building a new set of sums
#	which get stored in a localized file
#
#TAG=OSI

SUMDIR=/usr/local/etc/checksums
GUI=0
if [ "$1" = "gui" ]; then
	GUI=1
	shift
fi

if [ ! -d $SUMDIR ]; then
	echo "Cannot locate checksum database in $SUMDIR!!"
	cp /dev/null /tmp/done
	exit 1
fi
if [ ! -f $SUMDIR/scan.conf ]; then
	echo "No $SUMDIR/scan.conf!!"
	cp /dev/null /tmp/done
	exit 1
fi
if [ ! -x $SUMDIR/scan ]; then
	echo "No $SUMDIR/scan executable!!"
	cp /dev/null /tmp/done
	exit 1
fi


cd $SUMDIR

echo "Creating new system checksum database in $SUMDIR, please wait..."
rm -f /var/tmp/localize.$$
rm -f *.sum

./scan -w scan.conf -n gauntlet.sum >/dev/null
if [ $? -ne 0 ]; then
	echo "Scan Failed!!"
	cp /dev/null /tmp/done
	exit 1
fi


cp /dev/null /tmp/done
exit 0

