1 | #!/bin/bash |
---|
2 | ### BEGIN INIT INFO |
---|
3 | # Provides: invirt-console-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 console proxy server |
---|
9 | # Description: |
---|
10 | ### END INIT INFO |
---|
11 | |
---|
12 | # Author: Invirt project <invirt@mit.edu> |
---|
13 | |
---|
14 | # Do NOT "set -e" |
---|
15 | |
---|
16 | # PATH should only include /usr/* if it runs after the mountnfs.sh script |
---|
17 | PATH=/sbin:/usr/sbin:/bin:/usr/bin |
---|
18 | DESC="the Invirt console server" |
---|
19 | NAME=invirt-console-server |
---|
20 | DAEMON=/usr/bin/invirt-consolefs |
---|
21 | MOUNTPOINT="/consolefs" |
---|
22 | DAEMON_ARGS="-f $MOUNTPOINT" |
---|
23 | PIDFILE=/var/run/$NAME.pid |
---|
24 | SCRIPTNAME=/etc/init.d/$NAME |
---|
25 | GEN_FILES=(/etc/conserver/invirt-hosts.cf |
---|
26 | /etc/remctl/acl/invirt-console-server |
---|
27 | /etc/issue.net.no_tkt |
---|
28 | /etc/nss-pgsql.conf) |
---|
29 | |
---|
30 | # Exit if the package is not installed |
---|
31 | [ -x "$DAEMON" ] || exit 0 |
---|
32 | |
---|
33 | . /lib/init/gen-files.sh |
---|
34 | . /lib/init/std-init.sh |
---|
35 | |
---|
36 | # |
---|
37 | # Function that starts the daemon/service |
---|
38 | # |
---|
39 | do_start() |
---|
40 | { |
---|
41 | # Return |
---|
42 | # 0 if daemon has been started |
---|
43 | # 1 if daemon was already running |
---|
44 | # 2 if daemon could not be started |
---|
45 | |
---|
46 | # Try to make sure fuse is setup |
---|
47 | [ -e /dev/fuse ] || modprobe fuse || return 2 |
---|
48 | |
---|
49 | if cat /proc/mounts | grep " $MOUNTPOINT " >/dev/null 2>&1; then |
---|
50 | return 1 |
---|
51 | fi |
---|
52 | |
---|
53 | gen_files |
---|
54 | |
---|
55 | daemon -r -O daemon.info -E daemon.err -n $NAME -- $DAEMON $DAEMON_ARGS || return 2 |
---|
56 | } |
---|
57 | |
---|
58 | # |
---|
59 | # Function that stops the daemon/service |
---|
60 | # |
---|
61 | do_stop() |
---|
62 | { |
---|
63 | # Return |
---|
64 | # 0 if daemon has been stopped |
---|
65 | # 1 if daemon was already stopped |
---|
66 | # 2 if daemon could not be stopped |
---|
67 | # other if a failure occurred |
---|
68 | |
---|
69 | if ! cat /proc/mounts | grep " $MOUNTPOINT " >/dev/null 2>&1; then |
---|
70 | return 1 |
---|
71 | fi |
---|
72 | |
---|
73 | daemon --stop -n $NAME |
---|
74 | RETVAL="$?" |
---|
75 | [ "$RETVAL" = 2 ] && return 2 |
---|
76 | # Many daemons don't delete their pidfiles when they exit. |
---|
77 | rm -f $PIDFILE |
---|
78 | } |
---|
79 | |
---|
80 | do_reload() |
---|
81 | { |
---|
82 | gen_config |
---|
83 | invoke-rc.d conserver-server reload |
---|
84 | } |
---|
85 | |
---|
86 | std_init "$1" |
---|