1#!/bin/sh 2### BEGIN INIT INFO 3# Provides: fuse 4# Required-Start: 5# Should-Start: udev 6# Required-Stop: 7# Default-Start: S 8# Default-Stop: 9# Short-Description: Start and stop fuse. 10# Description: Load the fuse module and mount the fuse control 11# filesystem. 12### END INIT INFO 13 14set -e 15 16PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 17MOUNTPOINT=/sys/fs/fuse/connections 18 19# Gracefully exit if the package has been removed. 20which fusermount3 &>/dev/null || exit 5 21 22# Define LSB log_* functions. 23. /lib/lsb/init-functions 24 25case "$1" in 26 start|restart|force-reload) 27 if ! grep -qw fuse /proc/filesystems; then 28 echo -n "Loading fuse module" 29 if ! modprobe fuse >/dev/null 2>&1; then 30 echo " failed!" 31 exit 1 32 else 33 echo "." 34 fi 35 else 36 echo "Fuse filesystem already available." 37 fi 38 if grep -qw fusectl /proc/filesystems && \ 39 ! grep -qw $MOUNTPOINT /proc/mounts; then 40 echo -n "Mounting fuse control filesystem" 41 if ! mount -t fusectl fusectl $MOUNTPOINT >/dev/null 2>&1; then 42 echo " failed!" 43 exit 1 44 else 45 echo "." 46 fi 47 else 48 echo "Fuse control filesystem already available." 49 fi 50 ;; 51 stop) 52 if ! grep -qw fuse /proc/filesystems; then 53 echo "Fuse filesystem not loaded." 54 exit 7 55 fi 56 if grep -qw $MOUNTPOINT /proc/mounts; then 57 echo -n "Unmounting fuse control filesystem" 58 if ! umount $MOUNTPOINT >/dev/null 2>&1; then 59 echo " failed!" 60 else 61 echo "." 62 fi 63 else 64 echo "Fuse control filesystem not mounted." 65 fi 66 if grep -qw "^fuse" /proc/modules; then 67 echo -n "Unloading fuse module" 68 if ! rmmod fuse >/dev/null 2>&1; then 69 echo " failed!" 70 else 71 echo "." 72 fi 73 else 74 echo "Fuse module not loaded." 75 fi 76 ;; 77 status) 78 echo -n "Checking fuse filesystem" 79 if ! grep -qw fuse /proc/filesystems; then 80 echo " not available." 81 exit 3 82 else 83 echo " ok." 84 fi 85 ;; 86 *) 87 echo "Usage: $0 {start|stop|restart|force-reload|status}" 88 exit 1 89 ;; 90esac 91 92exit 0 93