#!/sbin/sh
#
# @(#) $Revision: 78.2 $
#
# NOTE:    This script is not configurable!  Any changes made to this
#          scipt will be overwritten when you upgrade to the next
#          release of HP-UX.
#
# WARNING: Changing this script in any way may lead to a system that
#          is unbootable.  Do not modify this script.
#

#
# Mount local filesystems and start quotas
#

PATH=/sbin:/usr/sbin:/usr/bin
export PATH

rval=0
set_return() {
	x=$?
	if [ $x -ne 0 ]; then
		echo "EXIT CODE: $x"
		rval=1
	fi
}

case $1 in
start_msg)
	echo "Mount file systems"
	;;

stop_msg)
	echo "Unmount file systems"
	;;

'start')
	# Mount all local volumes listed in /etc/fstab
	/sbin/mountall -l -m
	set_return

	# enable quotas on the root file system
	# (others were enabled by mount)
	if [ -f /quotas -a -x /usr/sbin/quotaon ]; then
		/usr/sbin/quotaon -v /
		set_return
	fi

	# Preen quota statistics
	if [ -x /usr/sbin/quotacheck ]; then
		echo checking quotas
	fi
	for i in `awk  ' 
	$1 !~ /^#/ { if ($3) 
       		if ($3 != "swap" && $3 != "noswap" && $3 != "ignore")
			types[$3] += 1
	}
	END 	{ for (i in types) 
			printf ("%s ", i);
		printf ("\n");
	} ' /etc/fstab ` 
	do
		case $i in
			hfs)	quotacheck -F $i -a -P	# preen quota stats
				set_return
				;;
			vxfs)	quotacheck -F $i -a	# no preen, but syncs stats file
				set_return
				;;
			*)	# no quotas kept on any other filesystem type
				set_return
				;;
		esac
	done
	;;

'stop')

	# Unmount the local volumes listed in /etc/fstab
	/sbin/umountall -l
	set_return

	;;

*)
	echo "usage: $0 {start}"
	;;
esac

exit $rval
