1 | #! /bin/sh |
---|
2 | ### BEGIN INIT INFO |
---|
3 | # Provides: invirt-remote-server |
---|
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 |
---|
8 | # Short-Description: Invirt remctl configuration filesystem |
---|
9 | # Description: |
---|
10 | ### END INIT INFO |
---|
11 | |
---|
12 | # Author: Invirt project <invirt@mit.edu> |
---|
13 | |
---|
14 | PATH=/sbin:/usr/sbin:/bin:/usr/bin |
---|
15 | NAME=invirt-remote-server |
---|
16 | DESC="the Invirt remctl configuration filesystem" |
---|
17 | DAEMON=/usr/sbin/invirt-remconffs |
---|
18 | MOUNTPOINT="/etc/remctl/remconffs" |
---|
19 | DAEMON_ARGS="-f $MOUNTPOINT" |
---|
20 | PIDFILE=/var/run/$NAME.pid |
---|
21 | SCRIPTNAME=/etc/init.d/$NAME |
---|
22 | GEN_FILES=/etc/remctl/acl/web |
---|
23 | |
---|
24 | # Exit if the package is not installed |
---|
25 | [ -x "$DAEMON" ] || exit 0 |
---|
26 | |
---|
27 | . /lib/init/gen-files.sh |
---|
28 | . /lib/init/std-init.sh |
---|
29 | |
---|
30 | # |
---|
31 | # Function that starts the daemon/service |
---|
32 | # |
---|
33 | do_start() |
---|
34 | { |
---|
35 | # Return |
---|
36 | # 0 if daemon has been started |
---|
37 | # 1 if daemon was already running |
---|
38 | # 2 if daemon could not be started |
---|
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 | |
---|
47 | gen_files |
---|
48 | |
---|
49 | daemon -r -O daemon.info -E daemon.err -n $NAME -- $DAEMON $DAEMON_ARGS || return 2 |
---|
50 | } |
---|
51 | |
---|
52 | # |
---|
53 | # Function that stops the daemon/service |
---|
54 | # |
---|
55 | do_stop() |
---|
56 | { |
---|
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 |
---|
62 | |
---|
63 | if ! cat /proc/mounts | grep " $MOUNTPOINT " >/dev/null 2>&1; then |
---|
64 | return 1 |
---|
65 | fi |
---|
66 | |
---|
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 |
---|
72 | } |
---|
73 | |
---|
74 | do_reload() |
---|
75 | { |
---|
76 | gen_config |
---|
77 | } |
---|
78 | |
---|
79 | std_init "$1" |
---|