Add init script
[fuse.git] / util / init_script
blobed964cbc7fb6e99c6262ca9488f55b3f47123067
1 #! /bin/sh
3 # fuse Init script for Filesystem in Userspace
5 # Author: Miklos Szeredi <miklos@szeredi.hu>
7 set -e
9 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
10 SCRIPTNAME=/etc/init.d/fuse
11 DESC="FUSE"
12 MOUNTPOINT=/sys/fs/fuse/connections
14 # Gracefully exit if the package has been removed.
15 test -x `which fusermount` || exit 0
17 error()
19 echo "Error $1" >&2
20 exit 1
23 case "$1" in
24 start)
25 echo -n "Starting $DESC: "
26 if ! grep -qw fuse /proc/filesystems; then
27 modprobe fuse >/dev/null 2>&1 || error "loading fuse module"
29 if grep -qw fusectl /proc/filesystems && \
30 ! grep -qw $MOUNTPOINT /proc/mounts; then
31 mount -t fusectl none $MOUNTPOINT >/dev/null 2>&1 || \
32 error "mounting control filesystem"
34 echo "done."
36 stop)
37 echo -n "Stopping $DESC: "
38 if grep -qw $MOUNTPOINT /proc/mounts; then
39 umount $MOUNTPOINT >/dev/null 2>&1 || \
40 error "unmounting control filesystem"
42 if grep -qw "^fuse" /proc/modules; then
43 rmmod fuse >/dev/null 2>&1 || error "unloading fuse module"
45 echo "done."
48 echo "Usage: $SCRIPTNAME {start|stop}" >&2
49 exit 1
51 esac
53 exit 0