From: Miklos Szeredi Date: Fri, 27 Apr 2007 21:07:45 +0000 (+0000) Subject: Clean up init script, make it LSB compliant X-Git-Tag: fuse_2_7_0_rc1~5 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=f7a8e087dc689c9a1a595c3ca0a013f4d5035140;p=qemu-gpiodev%2Flibfuse.git Clean up init script, make it LSB compliant --- diff --git a/ChangeLog b/ChangeLog index 12e78a6..a698158 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ * libfuse: call umount(8) directly instead of fusermount if possible + * Clean up init script, make it LSB compliant + 2007-04-26 Miklos Szeredi * In multithreaded loop, use a semaphore instead of SIGHUP to wake diff --git a/util/init_script b/util/init_script index 2d1bd29..331b33a 100755 --- a/util/init_script +++ b/util/init_script @@ -1,51 +1,87 @@ #! /bin/sh -# -# fuse Init script for Filesystem in Userspace -# -# Author: Miklos Szeredi +### BEGIN INIT INFO +# Provides: fuse +# Required-Start: +# Should-Start: udev +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Start and stop fuse. +# Description: Load the fuse module and mount the fuse control +# filesystem. +### END INIT INFO set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -SCRIPTNAME=/etc/init.d/fuse -DESC="FUSE" MOUNTPOINT=/sys/fs/fuse/connections # Gracefully exit if the package has been removed. -which fusermount &>/dev/null || exit 0 - -error() -{ - echo "Error $1" >&2 - exit 1 -} +which fusermount &>/dev/null || exit 5 case "$1" in - start) - echo -n "Starting $DESC: " + start|restart|force-reload) if ! grep -qw fuse /proc/filesystems; then - modprobe fuse >/dev/null 2>&1 || error "loading fuse module" + echo -n "Loading fuse module" + if ! modprobe fuse >/dev/null 2>&1; then + echo " failed!" + exit 1 + else + echo "." + fi + else + echo "Fuse filesystem already available." fi if grep -qw fusectl /proc/filesystems && \ ! grep -qw $MOUNTPOINT /proc/mounts; then - mount -t fusectl fusectl $MOUNTPOINT >/dev/null 2>&1 || \ - error "mounting control filesystem" + echo -n "Mounting fuse control filesystem" + if ! mount -t fusectl fusectl $MOUNTPOINT >/dev/null 2>&1; then + echo " failed!" + exit 1 + else + echo "." + fi + else + echo "Fuse control filesystem already available." fi - echo "done." ;; - stop) - echo -n "Stopping $DESC: " + stop) + if ! grep -qw fuse /proc/filesystems; then + echo "Fuse filesystem not loaded." + exit 7 + fi if grep -qw $MOUNTPOINT /proc/mounts; then - umount $MOUNTPOINT >/dev/null 2>&1 || \ - error "unmounting control filesystem" + echo -n "Unmounting fuse control filesystem" + if ! umount $MOUNTPOINT >/dev/null 2>&1; then + echo " failed!" + else + echo "." + fi + else + echo "Fuse control filesystem not mounted." fi if grep -qw "^fuse" /proc/modules; then - rmmod fuse >/dev/null 2>&1 || error "unloading fuse module" + echo -n "Unloading fuse module" + if ! rmmod fuse >/dev/null 2>&1; then + echo " failed!" + else + echo "." + fi + else + echo "Fuse module not loaded." + fi + ;; + status) + echo -n "Checking fuse filesystem" + if ! grep -qw fuse /proc/filesystems; then + echo " not available." + exit 3 + else + echo " ok." fi - echo "done." ;; *) - echo "Usage: $SCRIPTNAME {start|stop}" >&2 + echo "Usage: $0 {start|stop|restart|force-reload|status}" exit 1 ;; esac