#! /bin/sh
#

case "$1" in
  start)
     # Check quotas.
     if [ -x /usr/sbin/quotacheck ]
     then
        echo -n 'Checking quotas: ';
	/usr/sbin/quotacheck -a
        echo 'Done'

	# Make quota file sparse
	echo -n 'Making quota files sparse: '
	awk '/usrquota/ {print $2"/quota.user"}' /etc/mtab |
	xargs zum > /dev/null

	awk '/grpquota/ {print $2"/quota.group"}' /etc/mtab |
	xargs zum > /dev/null
	echo 'Done'
     fi 
     # Turn quotas on.
     if [ -x /usr/sbin/quotaon ]
     then
        echo 'Turning on quotas';
        /usr/sbin/quotaon -aug
     fi
    ;;
  stop)
     if [ -x /usr/sbin/quotaoff ]
     then
	echo "Turning off quotas"
	/usr/sbin/quotaoff -a
     fi
    ;;
  *)
    echo "Usage: /etc/init.d/quota {start|stop}"
    exit 1
esac

exit 0
