On Wed, Feb 21, 2001 at 08:54:25AM -0800, Lee Allen wrote:
> I am planning to write some scripts to support vnc on Linux, and it
> seems I might be re-inventing the wheel. That is, has someone else
> already done this?
Yes, someone has already done this. See the latest vnc-server package
on Red Hat Rawhide.
It does almost what you suggest, only slightly better. ;-)
> 1. create a file containing a list of [vnc] user names
The file is called /etc/sysconfig/vncservers, and has a variable which
can take a list of space-separated displaynumber:username pairs.
> 2. create a startup script (ie, /etc/rc.d/init.d/vnc ) that does this:
> if argument = start:
> read each user name from the file
> check to see whether there is a vnc server running for that
> user, if not:
> start a vnc server process (use the user's UID as the vnc
> server number)
We have fixed display numbers per user, which is more predictable.
> 3. create a script to kill or kill-and-restart the vnc server for a
> single user name
Okay, we don't have that.
> One complication I am anticipating is the vnc password files. If they
> don't already exist, vncserver prompts for them, and that won't work.
We check for a password file first.
I'll append the initscript actually, since there have been some fixes
since Rawhide.
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 && [ -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
[demime 0.97b removed an attachment of type application/pgp-signature]
---------------------------------------------------------------------
To unsubscribe, send a message with the line: unsubscribe vnc-list
to [EMAIL PROTECTED]
See also: http://www.uk.research.att.com/vnc/intouch.html
---------------------------------------------------------------------