#!/bin/sh
# JLdL 29Aug06.
#
# Update all the binary quota files once a day.

# Check that the quotas-config package is available.
test -x /usr/sbin/multi-update-quotas || exit 0

# Check that the configuration file exists.
test -f /etc/quotas.conf || exit 0

# Check that the configuration directory exists.
test -d /etc/quotas || exit 0

# Define a variable containing the tab character.
tab=`echo -en '\t'`

# See if there is a cluster-wide quota directory configured.
cdir=`grep "^[ $tab]*set[ $tab]*cluster_dir" /etc/quotas.conf \
	| cut -d= -f2 | cut -d\" -f2`

# See if the automatic backup strategy is active.
bflg=`grep "^[ $tab]*set[ $tab]*backup_flag" /etc/quotas.conf \
	| cut -d= -f2 | cut -d\" -f2`

# See if there are any symbolic links in /etc/quotas.
slnk=`find /etc/quotas -type l`

# In any of these cases, update all the binary quota files.
if [ "$cdir" != "" ] || [ "$bflg" = "1" ] || [ "$slnk" != "" ]; then
	# Run the program quietly.
	/usr/sbin/multi-update-quotas -q
fi

exit 0
