#! @SHELL@
#
# Copyright 2004 Double Precision, Inc.
# See COPYING for distribution information.
#
# Sample script to safely update shared folder index files.

prefix="@prefix@"
sysconfdir="@sysconfdir@"

shareddir="$sysconfdir/shared"  # Where the shared index files are kept

newshareddir="$sysconfdir/shared.tmp" # Updated shared index

if test `ls "$newshareddir" | wc -l` = 0
then
	echo "$newshareddir is empty!"
	exit 1   # Sanity check
fi

if test ! -d "$shareddir"
then
	echo "$shareddir does not exist!"
	exit 1
fi

# First, remove obsoleted files

ls "$shareddir" | while read F
do
	test -f "$newshareddir/$F" || rm -f "$shareddir/$F"
done

mv -f "$newshareddir"/* "$shareddir"
