[273] | 1 | #! /bin/sh |
---|
| 2 | ### BEGIN INIT INFO |
---|
[1386] | 3 | # Provides: invirt-vnc-server |
---|
[273] | 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 |
---|
[1386] | 8 | # Short-Description: Invirt VNC Proxy Server |
---|
[273] | 9 | # Description: |
---|
| 10 | ### END INIT INFO |
---|
| 11 | |
---|
[1386] | 12 | # Author: Invirt project <invirt@mit.edu> |
---|
[273] | 13 | |
---|
| 14 | # Do NOT "set -e" |
---|
| 15 | |
---|
| 16 | # PATH should only include /usr/* if it runs after the mountnfs.sh script |
---|
[1399] | 17 | PACKAGE=invirt-vnc-server |
---|
[1386] | 18 | DESC="The Invirt VNC Proxy Server" |
---|
| 19 | DAEMON=/usr/sbin/invirt-vnc-server |
---|
[273] | 20 | DAEMON_ARGS="" |
---|
| 21 | PIDFILE=/var/run/$NAME.pid |
---|
| 22 | SCRIPTNAME=/etc/init.d/$NAME |
---|
| 23 | |
---|
| 24 | # Exit if the package is not installed |
---|
| 25 | [ -x "$DAEMON" ] || exit 0 |
---|
| 26 | |
---|
[1399] | 27 | . /lib/init/std-init.sh |
---|
[273] | 28 | |
---|
| 29 | # |
---|
| 30 | # Function that starts the daemon/service |
---|
| 31 | # |
---|
| 32 | do_start() |
---|
| 33 | { |
---|
| 34 | # Return |
---|
| 35 | # 0 if daemon has been started |
---|
| 36 | # 1 if daemon was already running |
---|
| 37 | # 2 if daemon could not be started |
---|
| 38 | daemon --running -n $NAME && return 1 |
---|
[1399] | 39 | daemon -r -U -O daemon.info -E daemon.err -n $NAME -U $DAEMON $DAEMON_ARGS || return 2 |
---|
[273] | 40 | } |
---|
| 41 | |
---|
| 42 | # |
---|
| 43 | # Function that stops the daemon/service |
---|
| 44 | # |
---|
| 45 | do_stop() |
---|
| 46 | { |
---|
| 47 | # Return |
---|
| 48 | # 0 if daemon has been stopped |
---|
| 49 | # 1 if daemon was already stopped |
---|
| 50 | # 2 if daemon could not be stopped |
---|
| 51 | # other if a failure occurred |
---|
| 52 | daemon --stop -n $NAME |
---|
| 53 | RETVAL="$?" |
---|
| 54 | [ "$RETVAL" = 2 ] && return 2 |
---|
| 55 | # Many daemons don't delete their pidfiles when they exit. |
---|
| 56 | rm -f $PIDFILE |
---|
| 57 | return "$RETVAL" |
---|
| 58 | } |
---|
| 59 | |
---|
[1399] | 60 | std_init "$1" |
---|