| 1 | #! /bin/sh |
|---|
| 2 | ### BEGIN INIT INFO |
|---|
| 3 | # Provides: invirt-vnc-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 VNC 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 | PACKAGE=invirt-vnc-server |
|---|
| 18 | DESC="The Invirt VNC Proxy Server" |
|---|
| 19 | DAEMON=/usr/sbin/invirt-vnc-server |
|---|
| 20 | DAEMON_ARGS="" |
|---|
| 21 | PIDFILE=/var/run/$PACKAGE.pid |
|---|
| 22 | SCRIPTNAME=/etc/init.d/$PACKAGE |
|---|
| 23 | |
|---|
| 24 | # Exit if the package is not installed |
|---|
| 25 | [ -x "$DAEMON" ] || exit 0 |
|---|
| 26 | |
|---|
| 27 | . /lib/init/std-init.sh |
|---|
| 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 $PACKAGE && return 1 |
|---|
| 39 | daemon -r -U -O daemon.info -E daemon.err -n $PACKAGE -U $DAEMON $DAEMON_ARGS || return 2 |
|---|
| 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 $PACKAGE |
|---|
| 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 | |
|---|
| 60 | std_init "$1" |
|---|