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