[843] | 1 | #!/bin/bash |
---|
[335] | 2 | ### BEGIN INIT INFO |
---|
[1200] | 3 | # Provides: invirt-console-server |
---|
[335] | 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 |
---|
[1200] | 8 | # Short-Description: Invirt console proxy server |
---|
[335] | 9 | # Description: |
---|
| 10 | ### END INIT INFO |
---|
| 11 | |
---|
[1222] | 12 | # Author: Invirt project <invirt@mit.edu> |
---|
[335] | 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 |
---|
[1200] | 18 | DESC="the Invirt console server" |
---|
| 19 | NAME=invirt-console-server |
---|
| 20 | DAEMON=/usr/bin/invirt-consolefs |
---|
[1741] | 21 | MOUNTPOINT="/consolefs" |
---|
| 22 | DAEMON_ARGS="-f $MOUNTPOINT" |
---|
[335] | 23 | PIDFILE=/var/run/$NAME.pid |
---|
| 24 | SCRIPTNAME=/etc/init.d/$NAME |
---|
[1747] | 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) |
---|
[335] | 29 | |
---|
| 30 | # Exit if the package is not installed |
---|
| 31 | [ -x "$DAEMON" ] || exit 0 |
---|
| 32 | |
---|
[1747] | 33 | . /lib/init/gen-files.sh |
---|
[1742] | 34 | . /lib/init/std-init.sh |
---|
[335] | 35 | |
---|
| 36 | # |
---|
| 37 | # Function that starts the daemon/service |
---|
| 38 | # |
---|
| 39 | do_start() |
---|
| 40 | { |
---|
[1740] | 41 | # Return |
---|
| 42 | # 0 if daemon has been started |
---|
| 43 | # 1 if daemon was already running |
---|
| 44 | # 2 if daemon could not be started |
---|
[1741] | 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 | |
---|
[1747] | 53 | gen_files |
---|
[1741] | 54 | |
---|
| 55 | daemon -r -O daemon.info -E daemon.err -n $NAME -- $DAEMON $DAEMON_ARGS || return 2 |
---|
[335] | 56 | } |
---|
| 57 | |
---|
| 58 | # |
---|
| 59 | # Function that stops the daemon/service |
---|
| 60 | # |
---|
| 61 | do_stop() |
---|
| 62 | { |
---|
[1740] | 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 |
---|
[1741] | 68 | |
---|
| 69 | if ! cat /proc/mounts | grep " $MOUNTPOINT " >/dev/null 2>&1; then |
---|
| 70 | return 1 |
---|
| 71 | fi |
---|
| 72 | |
---|
[1740] | 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 |
---|
[335] | 78 | } |
---|
| 79 | |
---|
[699] | 80 | do_reload() |
---|
| 81 | { |
---|
[1752] | 82 | gen_files |
---|
[1740] | 83 | invoke-rc.d conserver-server reload |
---|
[699] | 84 | } |
---|
| 85 | |
---|
[1742] | 86 | std_init "$1" |
---|