Solution to "How do I start the vncserver automatically
(linux)"
zaphodb
zaphodb "at" casema.net
Thu, 26 Oct 2000 23:30:48 +0000
Hi, I've been experimenting with the idea of using su -c and the
rc.d facilities to start a server for a given user at boot time.
And it seems that following some of the list's suggestions
I've found a working solution I thought I should share with you.
.
This is what I did:
I made a vnc script and put it in /etc/rc.d/init.d
Its contents are:
-------------------
vnc
-------------------
#!/bin/sh
#
# Source function library.
. /etc/rc.d/init.d/functions
RETVAL=0
# See how we were called.
case "$1" in
start)
echo -n "Starting VNC services for user Joe: "
su -l -c /etc/rc.d/init.d/start_vncserver joe
RETVAL=$?
;;
stop)
echo -n "Shutting down VNC services: "
su -l -c /etc/rc.d/init.d/stop_vncserver joe
RETVAL=$?
;;
restart)
$0 stop
$0 start
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
-----------------------
Then I made 2 symbolic links to this file :
/etc/rc.d/rc.5/S92vnc -> /etc/rc.d/init.d/vnc
and
/etc/rc.d/rc.5/K36vnc -> /etc/rc.d/init.d/vnc
K36vnc stops the vnc service at shutdown or reboot
and S92vnc will start the vnc server when entering runlevel 5.
Runlevel 5 is used because the X-server is started at this runlevel.
The contents of the start_vncserver and stop_vncserver scripts are:
-----------------------
stop_vncserver
-----------------------
/usr/local/bin/vncserver -kill :1
-----------------------
start_vncserver
-----------------------
# Just in case a lock file was not deleted
# now is a good time to get rid of it.
#
/usr/bin/rm /tmp/.X1-lock
#
/usr/local/bin/vncserver -cc 3 -geometry 1024x768 :1
I had to use the start_vncserver and stop_vncserver scripts as
a go between because the su command didn't accept
as many options as I needed.
Greetz,
Zaphod
---------------------------------------------------------------------
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
---------------------------------------------------------------------