init script for vncreflector

|
Here's an init script for vncreflector I threw together.  It's a hacked up copy of the init script for vncserver.  Ideally, it would handle multiple instances of vncreflector like the vncserver init script does, but that will have to wait until I have some more time (read: until I actually need multiple instances of vncreflector running).
#!/bin/bash
#
# chkconfig: - 91 35
# description: Starts and stops vncreflector. \
#              VNC Reflector is a specialized VNC server which acts \
#              as a proxy sitting between real VNC server (host) \
#              and a number of VNC clients.

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

unset VNCREFLECTORARGS
[ -f /etc/sysconfig/vncreflector ] && . /etc/sysconfig/vncreflector

prog=$"VNC Reflector"

start() {
    echo -n $"Starting $prog: "
    ulimit -S -c 0 >/dev/null 2>&1
    RETVAL=0
    unset BASH_ENV ENV
    initlog $INITLOG_ARGS -c \
        "vncreflector -q -g /var/log/reflector.log -i /var/run/vncreflector.pid -p /etc/vncreflector/passwd /etc/vncreflector/host_info"
    RETVAL=$?
    [ "$RETVAL" -ne 0 ] && break
    [ "$RETVAL" -eq 0 ] && success $"vncreflector startup" || \
        failure $"vncreflector start"
    echo
    [ "$RETVAL" -eq 0 ] && touch /var/lock/subsys/vncreflector
}

stop() {
    echo -n $"Shutting down $prog: "
    unset BASH_ENV ENV
    initlog $INITLOG_ARGS -c \
        "bash -c \". /etc/init.d/functions && killproc vncreflector\""
    RETVAL=$?
    [ "$RETVAL" -eq 0 ] && success $"vncreflector shutdown" || \
        failure $"vncreflector shutdown"
    echo
    [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/vncreflector
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        sleep 3
        start
        ;;
  condrestart)
        if [ -f /var/lock/subsys/vncreflector ]; then
            stop
            sleep 3
            start
        fi
        ;;
  status)
        status vncreflector
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        exit 1
esac

Leave a comment