#!/bin/sh
########################################################################
# Begin $rc_base/init.d/fuse
#
# Description : Filesystem in USErspace routines
#
# Authors     : Arthur D. <spinal.by@mail.ru>
#
# Version     : 00.00
#
# Notes       : Mon, 15 Dec 2008 17:01:38 +0200
#
########################################################################

. /etc/sysconfig/rc
. $rc_functions

MOUNTPOINT=/sys/fs/fuse/connections

error()
{
	echo_failure
	boot_mesg "$1" ${FAILURE}
	exit 1
}

case "$1" in
  start)
	boot_mesg "Starting fuse..."
	if ! grep -qw fuse /proc/filesystems; then
		modprobe fuse >/dev/null 2>&1 ||
		error "Unable to load module fuse."
	fi
	if grep -qw fusectl /proc/filesystems && \
	   ! grep -qw $MOUNTPOINT /proc/mounts; then
		mount -t fusectl none $MOUNTPOINT >/dev/null 2>&1 ||
		error "Unable to mount control filesystem."
	fi
#	mount -a -t fuse
	evaluate_retval
	;;
  stop)
	boot_mesg "Stopping fuse..."
#	umount -a -t fuse
	if grep -qw $MOUNTPOINT /proc/mounts; then
		umount $MOUNTPOINT >/dev/null 2>&1 ||
		error "Unable to unmount control filesystem."
	fi
	evaluate_retval
	;;
  *)
	echo "Usage: $0 {start|stop}" >&2
	exit 1
	;;
esac

# End $rc_base/init.d/fuse
