#! /sbin/sh

# (u)mount cache file systems

CONFIG=/etc/config
IS_ON=/sbin/chkconfig

# The verbose flag controls the printing of the names of daemons as they
# are started and the printing of NFS-mounted filesystem names as they are
# mounted and unmounted.

if $IS_ON verbose ; then
	ECHO=echo
	VERBOSE=-v
	LOGGER='lfmt -l network -s warn'
else        # For a quiet startup and shutdown
	ECHO=:
	VERBOSE=
	LOGGER='lfmt -l network -s warn -G 3'
fi

cd /

case $1 in
'start')
	;;

'netstart')
	if $IS_ON cachefs
	then

		$ECHO "Mounting cache file systems:"

		if /sbin/mount $VERBOSE `cat $CONFIG/cachefs.options 2> /dev/null` -at cachefs
		then :
		else
		    $LOGGER "Some cache file systems failed to mount.\n"
		fi

	fi
	;;

'stop')
	;;

'netstop')
	if $IS_ON cachefs
	then
		$ECHO "Unmounting cache file systems:"
	fi
	sync
	/sbin/umount $VERBOSE -akt cachefs
	sync
	/sbin/killall cachefs_replacement
	;;

*)
	$ECHO "usage: /etc/init.d/cachefs {start|stop}"
	;;
esac
