#!/bin/sh

#
# !!! THIS SCRIPT IS FOR USE WITH FMbackup                              !!!
# !!! @(#)mac32 for FMbackup version 1.0.4                              !!!
#
# NOTES:
#
# FMbackup is aware of the exit status of this script, and
# will display a final window with the message "Backup Failed!"
# if the exit status is non-zero.   The "magic cookie" FMEXIT is
# interpreted to mean stop looking for messages from this script
# and wait for this shell to terminate.
#

if [ -z "$SYSTEMFOLDER" ]; then
	echo "The SYSTEMFOLDER environment variable is not set."
	sleep 5
	echo "FMEXIT"
	exit 1
fi

cd "$SYSTEMFOLDER"

if [ -z "$DESKFILE" ]; then
	echo "The DESKFILE environment variable is not set."
	sleep 5
	echo "FMEXIT"
	exit 1
fi

echo "Backing up your file system cache..."

trap "" 2 3	# ignore SIGINT and SIGQUIT
/bin/find .fs_cache -print \
	| cpio -ocB 2>/dev/null | compress > "$DESKFILE"
trap 2 3	# reset SIGINT and SIGQUIT

echo "Finishing up..."
sleep 3
echo "FMEXIT"
exit 0
