HomeBanner

Installation instructions for VNC under SuSE 8.1

Installation instructions for VNC under SuSE 8.1

Dr. Willem van der Mark

I am using vnc (Release 3.3.3.r2-362) under SuSE 8.1.

If you don't have it installed get it from SuSE 'YAST2 Control Center': Install or Remove Software: Package Groups: X11: Utilities. You can then also try for 'Online update' to see if there is a newer version.

You will get files in:

/usr/X11R6/bin/ (Xvnc,vncpasswd, vncserver, vncviewer)
/usr/share/doc/packages/vnc (Documentation)
/usr/share/vnc/classes/ (Java classes for jvncviewer)
    

The script vncserver is a wrapper for Xvnc. I have changed the startup environment because I am using KDE. The change is on line 47; it now reads: startkde #&\n); The modified 'vncserver' is shown below.


. . .
. . .
$defaultXStartup
    = ("#!/bin/sh\n\n".
       "xrdb \$HOME/.Xresources\n".
       "xsetroot -solid grey\n".
       "xterm -geometry 80x24+10+10 -ls -title \"\$VNCDESKTOP Desktop\" &\n".
       "startkde &\n");

chop($host = `uname -n`);

. . .
. . .

In my setup I wanted to have the vncservers to come up at boot time and keep their context even after disconnecting the vnc-viewer. Some people prefer to start VNC through inetd, but this always gives you a fresh desktop and is also slow in starting up. I don't think that in my configuration I have a security issue; the server is behind a firewall with only http and smtp ports open. The local network is purely private (home LAN).

In order to achieve this I created a boot script called xvncserver under /etc/init.d which is included below as xvncserver.


#! /bin/sh
#
# Author: Willem van der Mark <wvdmark@computer.org>
#
# /etc/init.d/xvncserver	this Script
# /usr/sbin/rcvncserver		Root-Link to this Script
# /usr/X11R6/bin/vncserver	Program
#
# System startup script for vnc server
#
# LSB compatible service control script; see http://www.linuxbase.org/spec/
# 
# Note: This template uses functions rc_XXX defined in /etc/rc.status on
# UnitedLinux (UL) based Linux distributions. If you want to base your 
# script on this template and ensure that it works on non UL based LSB 
# compliant Linux distributions, you either have to provide the rc.status
# functions from UL or change the script to work without them.
#
#
### BEGIN INIT INFO
# Provides:       xvncserver
# Required-Start: $remote_fs $syslog $network xdm
# X-UnitedLinux-Should-Start: $network xdm
# Required-Stop:  $remote_fs $syslog $network xdm
# X-UnitedLinux-Should-Stop: $network xdm
# Default-Start:  3 5
# Default-Stop:   0 1 2 6
# Description:    Start vncserver for remote control
#	
### END INIT INFO


# Check for missing binaries
VNC_WRAPPER=/usr/X11R6/bin/vncserver
test -x $VNC_WRAPPER || exit 5
VNC_MASTER=/usr/X11R6/bin/Xvnc
test -x $VNC_MASTER || exit 5
VNC_CONFIG=/etc/sysconfig/vncservers
test -r $VNC_CONFIG || exit 5

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     ditto but be verbose in local rc status
#      rc_status -v -r  ditto and clear the local rc status
#      rc_failed        set local and overall rc status to failed
#      rc_failed <num>  set local and overall rc status to <num><num>
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status
#      rc_active	checks whether a service is activated by symlinks
. /etc/rc.status

# First reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# 

VNCSERVERS=""
VNCARGS=""
[ -f $VNC_CONFIG ] && . $VNC_CONFIG

prog=$"VNC server"

case "$1" in
    start)
		for display in ${VNCSERVERS}
		do
		if test -a /home/${display##*:}/.vnc/passwd ; then
			rm -fv /tmp/.X${display%%:*}-lock
			rm -fv /tmp/.X11-unix/X${display%%:*}
			echo -n "Starting $prog on: ${display} -- "
			su ${display##*:} -l -c "cd && vncserver :${display%%:*} ${VNCARGS}"
			[ $? -eq 0 ] && echo $rc_done_up || echo $rc_failed_up
		else
			echo -n "Vnc not initialised for user: ${display##*:}"
			echo $rc_failed ;
		fi
		done
    ;;
    stop)
		for display in ${VNCSERVERS}
		do
			echo -n "Shutting down $prog: ${display} "
			su ${display##*:} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
			[ $? -eq 0 ] && echo $rc_done || echo $rc_failed
		done
    ;;
    restart)
		$0 stop
		$0 start
		rc_status
    ;;
    status)
		echo -n "Checking for service Vnc-Server "
		## Check status with checkproc(8), if process is running
		## checkproc will return with exit status 0.

		# Return value is slightly different for the status command:
		# 0 - service running
		# 1 - service dead, but /var/run/  pid  file exists
		# 2 - service dead, but /var/lock/ lock file exists
		# 3 - service not running

		# NOTE: checkproc returns LSB compliant status values.
		checkproc $VNC_MASTER
		rc_status -v
    ;;
    *)
		echo "Usage: $0 {start|stop|status|restart}"
		exit 1
    ;;
esac
rc_exit

It is based on the skeleton provided in init.d and get its parameters from a file called 'vncservers' in /etc/sysconfig/. It contains 2 variables 'VNCSERVERS' and 'VNCARGS'. VNCSERVERS gives a series of 'screen number:user account' for each vnc-server you want to start. (not the root account; does not work, has not been tested, and it not recommendable). VNCARGS provides some extra parameters that will be passed to 'vncserver' or 'Xvnc'. This file is called vncservers. In this example the geometry of 940x705 prevents the vnc-viewer from clipping the Start bar in both Windows and Mac.


# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :1
# as my 'myusername' (a legal user).  This user will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.  
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, see
# URL:http://www.uk.research.att.com/vnc/sshvnc.html.
#
# VNCSERVERS="1:myusername ... ..."
#
VNCSERVERS="3:user1 4:user2"

# The VNCARGS variable contains arguments to vncserver (and Xvnc)
# which will be passed to all sessions; run 'man vncserver' or
# 'man Xvnc' to see which arguments are to be used.
#
# VNCARGS="-vncserversargs -Xvncargs"
#
VNCARGS="-geometry 940x705 -depth 16 -alwaysshared"

These options are then configurable in YAST2 'Editor for Sysconfig' under +etc: the following images

show the corresponding snapshots.

The boot-script xvncserver is installed with insserv /etc/init.d/xvncserver. Insserv enables an installed system init script (`boot script') by reading the comment header of the script and calculating the dependencies between all scripts. After executing this command we get the following boot sequences (symbolic links):

/etc/init.d/rc3.d/S17xvncserver
/etc/init.d/rc3.d/K06xvncserver
/etc/init.d/rc5.d/S17xvncserver
/etc/init.d/rc5.d/K06xvncserver
    

The YAST2 Runlevel editor will now show this information also.

In order to comply with the SuSE logic, we still need a link for the rc.. commands. Execute: ln -s /etc/init.d/xvncserver /sbin/rcvncserver OK. That's all.

When booting the machine two vncservers will be started in user1 (with screen 3) and in user2 (with screen 4) with the KDE desktop initialized and ready for being accessed by a vnc viewer. (I am using Win32 RealVNCViewer 3.3.7 on W2k and the VNCViewer or Chicken of the VNC viewers on Mac)


Updated: Tue, 03 Feb 2004
Valid CSS!Valid HTML 4.01!