#!/sbin/runscript

FUSECTL_SYSFS=/sys/fs/fuse/connections

depend()
{
	need localmount
}

start()
{
	ebegin "Starting fuse"
	if ! grep -qw fuse /proc/filesystems; then
		modprobe fuse >/dev/null 2>&1 || eend $?
	fi
	if grep -qw fusectl /proc/filesystems && \
		! grep -qw $FUSECTL_SYSFS /proc/mounts; then
		mount -t fusectl none $FUSECTL_SYSFS >/dev/null 2>&1 || eend $?
	fi
	eend
}

stop()
{
	ebegin "Stopping fuse"
	if grep -qw $FUSECTL_SYSFS /proc/mounts; then
		umount $FUSECTL_SYSFS >/dev/null 2>&1 || eend $?
	fi
	eend
}
