Miklos Szeredi | 4003dfa | 2006-10-01 13:46:02 +0000 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | # |
| 3 | # fuse Init script for Filesystem in Userspace |
| 4 | # |
| 5 | # Author: Miklos Szeredi <miklos@szeredi.hu> |
| 6 | |
| 7 | set -e |
| 8 | |
| 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 |
| 13 | |
| 14 | # Gracefully exit if the package has been removed. |
| 15 | test -x `which fusermount` || exit 0 |
| 16 | |
| 17 | error() |
| 18 | { |
| 19 | echo "Error $1" >&2 |
| 20 | exit 1 |
| 21 | } |
| 22 | |
| 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" |
| 28 | fi |
| 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" |
| 33 | fi |
| 34 | echo "done." |
| 35 | ;; |
| 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" |
| 41 | fi |
| 42 | if grep -qw "^fuse" /proc/modules; then |
| 43 | rmmod fuse >/dev/null 2>&1 || error "unloading fuse module" |
| 44 | fi |
| 45 | echo "done." |
| 46 | ;; |
| 47 | *) |
| 48 | echo "Usage: $SCRIPTNAME {start|stop}" >&2 |
| 49 | exit 1 |
| 50 | ;; |
| 51 | esac |
| 52 | |
| 53 | exit 0 |