[525] | 1 | #! /bin/sh |
---|
| 2 | ### BEGIN INIT INFO |
---|
[1176] | 3 | # Provides: invirt-remote-server |
---|
[525] | 4 | # Required-Start: $local_fs $remote_fs |
---|
| 5 | # Required-Stop: $local_fs $remote_fs |
---|
| 6 | # Default-Start: 2 3 4 5 |
---|
| 7 | # Default-Stop: 0 1 6 |
---|
[1176] | 8 | # Short-Description: Invirt remctl configuration filesystem |
---|
[525] | 9 | # Description: |
---|
| 10 | ### END INIT INFO |
---|
| 11 | |
---|
[1224] | 12 | # Author: Invirt project <invirt@mit.edu> |
---|
[525] | 13 | |
---|
| 14 | PATH=/sbin:/usr/sbin:/bin:/usr/bin |
---|
[1534] | 15 | NAME=invirt-remote-server |
---|
[1176] | 16 | DESC="the Invirt remctl configuration filesystem" |
---|
| 17 | DAEMON=/usr/sbin/invirt-remconffs |
---|
[1743] | 18 | MOUNTPOINT="/etc/remctl/remconffs" |
---|
| 19 | DAEMON_ARGS="-f $MOUNTPOINT" |
---|
[525] | 20 | PIDFILE=/var/run/$NAME.pid |
---|
| 21 | SCRIPTNAME=/etc/init.d/$NAME |
---|
[1534] | 22 | GEN_FILES=/etc/remctl/acl/web |
---|
[525] | 23 | |
---|
| 24 | # Exit if the package is not installed |
---|
| 25 | [ -x "$DAEMON" ] || exit 0 |
---|
| 26 | |
---|
[1534] | 27 | . /lib/init/gen-files.sh |
---|
| 28 | . /lib/init/std-init.sh |
---|
[525] | 29 | |
---|
[1743] | 30 | # |
---|
| 31 | # Function that starts the daemon/service |
---|
| 32 | # |
---|
[525] | 33 | do_start() |
---|
| 34 | { |
---|
[1740] | 35 | # Return |
---|
| 36 | # 0 if daemon has been started |
---|
| 37 | # 1 if daemon was already running |
---|
| 38 | # 2 if daemon could not be started |
---|
[1743] | 39 | |
---|
| 40 | # Try to make sure fuse is setup |
---|
| 41 | [ -e /dev/fuse ] || modprobe fuse || return 2 |
---|
| 42 | |
---|
| 43 | if cat /proc/mounts | grep " $MOUNTPOINT " >/dev/null 2>&1; then |
---|
| 44 | return 1 |
---|
| 45 | fi |
---|
| 46 | |
---|
[1746] | 47 | gen_files |
---|
[1743] | 48 | |
---|
| 49 | daemon -r -O daemon.info -E daemon.err -n $NAME -- $DAEMON $DAEMON_ARGS || return 2 |
---|
[525] | 50 | } |
---|
| 51 | |
---|
[1743] | 52 | # |
---|
| 53 | # Function that stops the daemon/service |
---|
| 54 | # |
---|
[525] | 55 | do_stop() |
---|
| 56 | { |
---|
[1740] | 57 | # Return |
---|
| 58 | # 0 if daemon has been stopped |
---|
| 59 | # 1 if daemon was already stopped |
---|
| 60 | # 2 if daemon could not be stopped |
---|
| 61 | # other if a failure occurred |
---|
[1743] | 62 | |
---|
| 63 | if ! cat /proc/mounts | grep " $MOUNTPOINT " >/dev/null 2>&1; then |
---|
| 64 | return 1 |
---|
| 65 | fi |
---|
| 66 | |
---|
[1740] | 67 | daemon --stop -n $NAME |
---|
| 68 | RETVAL="$?" |
---|
| 69 | [ "$RETVAL" = 2 ] && return 2 |
---|
| 70 | # Many daemons don't delete their pidfiles when they exit. |
---|
| 71 | rm -f $PIDFILE |
---|
[525] | 72 | } |
---|
| 73 | |
---|
[1743] | 74 | do_reload() |
---|
| 75 | { |
---|
[1752] | 76 | gen_files |
---|
[1743] | 77 | } |
---|
| 78 | |
---|
[1534] | 79 | std_init "$1" |
---|