vnc is in startup scripts(change user and home directory?)

Tim Waugh twaugh "at" redhat.com
Fri, 03 Aug 2001 23:47:38 +0000


On Fri, Aug 03, 2001 at 03:22:08PM -0700, Jared Kidd wrote:

> Ok, I got the redhat one and installed it.  I added a line for the user i
> wanted in /etc/sysconfig/vncservers.  Is that all i need to do?  will it
> now load a vnc server on the display specified in that file with the user
> and use that user's home directory?

That's the idea.  As for using the user's home directory, there was a
bug that was corrected since Red Hat Linux 7.1, so if you got the VNC
RPM from the Red Hat Rawhide directory on the FTP server you should be
alright.  I'll append the current script here anyway.

Don't forget to enable the vncserver service with 'chkconfig vncserver
on' (or by making the appropriate symlinks).

Tim.
*/

#!/bin/bash
#
# chkconfig: - 91 35
# description: Starts and stops vncserver. \
#	       used to provide remote X administration services.

# 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() {
    echo -n $"Starting $prog: "
    ulimit -S -c 0 >/dev/null 2>&1
    RETVAL=0
    for display in ${VNCSERVERS}
    do
        echo -n "${display} "
        initlog $INITLOG_ARGS -c \
            "su ${display##*:} -c \"cd ~${display##*:} && [ -f .vnc/passwd ] && vncserver :${display%%:*}\""
        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() {
    echo -n $"Shutting down $prog: "
    for display in ${VNCSERVERS}
    do
        echo -n "${display} "
	unset BASH_ENV ENV
        initlog $INITLOG_ARGS -c \
	    "su ${display##*:} -c \"vncserver -kill :${display%%:*} >/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
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|condrestart|status}"
	exit 1
esac
---------------------------------------------------------------------
To unsubscribe, send a message with the line: unsubscribe vnc-list
to majordomo "at" uk.research.att.com
See also: http://www.uk.research.att.com/vnc/intouch.html
---------------------------------------------------------------------