[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 |
---|
| 25 | |
---|
| 26 | # Exit if the package is not installed |
---|
| 27 | [ -x "$DAEMON" ] || exit 0 |
---|
| 28 | |
---|
[1742] | 29 | . /lib/init/std-init.sh |
---|
[335] | 30 | |
---|
[699] | 31 | gen_config() |
---|
| 32 | { |
---|
[888] | 33 | for i in /etc/conserver/invirt-hosts.cf \ |
---|
[1200] | 34 | /etc/remctl/acl/invirt-console-server \ |
---|
[888] | 35 | /etc/issue.net.no_tkt \ |
---|
| 36 | /etc/nss-pgsql.conf \ |
---|
| 37 | ; do |
---|
| 38 | mako-render $i.mako > $i |
---|
| 39 | done |
---|
[699] | 40 | } |
---|
| 41 | |
---|
[335] | 42 | # |
---|
| 43 | # Function that starts the daemon/service |
---|
| 44 | # |
---|
| 45 | do_start() |
---|
| 46 | { |
---|
[1740] | 47 | # Return |
---|
| 48 | # 0 if daemon has been started |
---|
| 49 | # 1 if daemon was already running |
---|
| 50 | # 2 if daemon could not be started |
---|
[1741] | 51 | |
---|
| 52 | # Try to make sure fuse is setup |
---|
| 53 | [ -e /dev/fuse ] || modprobe fuse || return 2 |
---|
| 54 | |
---|
| 55 | if cat /proc/mounts | grep " $MOUNTPOINT " >/dev/null 2>&1; then |
---|
| 56 | return 1 |
---|
| 57 | fi |
---|
| 58 | |
---|
[1740] | 59 | gen_config |
---|
[1741] | 60 | |
---|
| 61 | daemon -r -O daemon.info -E daemon.err -n $NAME -- $DAEMON $DAEMON_ARGS || return 2 |
---|
[335] | 62 | } |
---|
| 63 | |
---|
| 64 | # |
---|
| 65 | # Function that stops the daemon/service |
---|
| 66 | # |
---|
| 67 | do_stop() |
---|
| 68 | { |
---|
[1740] | 69 | # Return |
---|
| 70 | # 0 if daemon has been stopped |
---|
| 71 | # 1 if daemon was already stopped |
---|
| 72 | # 2 if daemon could not be stopped |
---|
| 73 | # other if a failure occurred |
---|
[1741] | 74 | |
---|
| 75 | if ! cat /proc/mounts | grep " $MOUNTPOINT " >/dev/null 2>&1; then |
---|
| 76 | return 1 |
---|
| 77 | fi |
---|
| 78 | |
---|
[1740] | 79 | daemon --stop -n $NAME |
---|
| 80 | RETVAL="$?" |
---|
| 81 | [ "$RETVAL" = 2 ] && return 2 |
---|
| 82 | # Many daemons don't delete their pidfiles when they exit. |
---|
| 83 | rm -f $PIDFILE |
---|
[335] | 84 | } |
---|
| 85 | |
---|
[699] | 86 | do_reload() |
---|
| 87 | { |
---|
[1740] | 88 | gen_config |
---|
| 89 | invoke-rc.d conserver-server reload |
---|
[699] | 90 | } |
---|
| 91 | |
---|
[1742] | 92 | std_init "$1" |
---|