Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-release > by-pkgid > 70e794a040a11cd653ec5cc3d796bab4 > files > 1

tightvnc-server-1.3.9-12mdv2008.1.x86_64.rpm

#!/bin/bash
#
# chkconfig: - 91 35
# description: Starts and stops vncserver. \
#	       used to provide remote X administration services.
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 5
# Short-Description: VNC server
# Description: Provides remote X administration services
### END INIT INFO

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

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

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

VNCSERVERS=""
[ -f /etc/sysconfig/vncservers ] && . /etc/sysconfig/vncservers

prog=$"VNC server"

start() {
    gprintf "Starting %s: " "$prog"
    ulimit -S -c 0 >/dev/null 2>&1
    RETVAL=0
    for display in ${VNCSERVERS}
    do
        gprintf "%s " "${display}"
        VNCNUMBER=${display%%:*}
        display=${display#*:}:
        VNCUSER=${display%%:*}
        VNCOPTIONS=`echo "${display#*:}" | tr : ' '`
        initlog $INITLOG_ARGS -c \
	"su --login $VNCUSER -c \"cd ~$VNCUSER && [ -f .vnc/passwd ] && vncserver :$VNCNUMBER $VNCOPTIONS\""
         RETVAL=$?
        [ "$RETVAL" -ne 0 ] && break
    done
    [ "$RETVAL" -eq 0 ] && success $"vncserver startup" || \
        failure "vncserver start"
    echo
    [ "$RETVAL" -eq 0 ] && touch /var/lock/subsys/vncserver
}

stop() {
    gprintf "Shutting down %s: " "$prog"
    for display in ${VNCSERVERS}
    do
        gprintf "%s " "${display}"
	unset BASH_ENV ENV
        VNCNUMBER=${display%%:*}
        display=${display#*:}:
        VNCUSER=${display%%:*}
        VNCOPTIONS=`echo "${display#*:}" | tr : ' '`
        initlog $INITLOG_ARGS -c \
	    "su $VNCUSER -c \"vncserver -kill :$VNCNUMBER >/dev/null 2>&1\""
    done
    RETVAL=$?
    [ "$RETVAL" -eq 0 ] && success $"vncserver shutdown" || \
        failure "vncserver shutdown"
    echo
    [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/vncserver
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|reload)
	stop
	start
	;;
  condrestart)
	if [ -f /var/lock/subsys/vncserver ]; then
	    stop
	    start
	fi
	;;
  status)
	status Xvnc
	;;
  *)
	gprintf "Usage: %s {start|stop|restart|condrestart|status}\n" "$0"
	exit 1
esac