9336d98a19f398e394c3b47b6712643cb59702ed
[nodemanager.git] / initscripts / fuse-pl
1 #!/bin/bash
2 #
3 # fuse-pl      Start FUSE support on PlanetLab
4 #
5 # chkconfig: 3 87 27
6 # description: Start FUSE support on PlanetLab
7 #
8
9 # Source function library.
10 . /etc/init.d/functions
11
12 : ${UTIL_VSERVER_VARS:=`echo /usr/lib*/util-vserver/util-vserver-vars`}
13 test -e "$UTIL_VSERVER_VARS" || {
14     echo "Can not find util-vserver installation; aborting..."
15     exit 1
16 }
17 . "$UTIL_VSERVER_VARS"
18
19
20 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
21 MOUNTPOINT=/sys/fs/fuse/connections
22
23 case "$1" in
24     start|restart|reload)
25         shift
26         # stolen from the /etc/init.d/fuse that comes with the fuse source
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 0
32                 else
33                         echo "."
34                 fi
35         fi
36         if grep -qw fusectl /proc/filesystems && \
37            ! grep -qw $MOUNTPOINT /proc/mounts; then
38                 echo -n "Mounting fuse control filesystem"
39                 if ! mount -t fusectl fusectl $MOUNTPOINT >/dev/null 2>&1; then
40                         echo " failed!"
41                         exit 1
42                 else
43                         echo "."
44                 fi
45         fi
46         # end stolen code
47         #
48         # To enable FUSE for existing slices, copy the FUSE device
49         # node into the slice
50         if [ ! -e /dev/fuse ]; then
51             echo "No FUSE device!  Exiting."
52             exit -1
53         fi
54         for slice in `ls $__CONFDIR`; do
55             cp -a /dev/fuse $__DEFAULT_VSERVERDIR/$slice/dev/ > /dev/null 2>&1
56         done
57         ;;
58     stop)
59         ;;
60     *)
61         echo $"Usage: $0 {start|restart|stop}"
62         exit 1
63 esac
64
65 exit 0