Wikia

coLinux

VNC On Bootup

Talk2
235pages on
this wiki

Redirected from VNC-On-Bootup

Fedora Core and other Redhat derived distributions Edit

These distributions ship with out-of-the-box support for automated VNC servers. Specifically this section was tested on Fedora Core 2. Firstly you must ensure the vnc-server package has been installed (for FC2 this is called vnc-server-4.0-1.beta4.11). You should also ensure you can run the vncserver correctly using your normal user code (this allows you to select the session password).

Next you should edit /etc/sysconfig/vncservers to specify which users will have VNC sessions started automatically. It is possible to run multiple VNC servers (VNCSERVERS is a white space separated list) but usually you would just run a session as your normal user code. In my case this file includes the following:

VNCSERVERS="1:drt"
VNCSERVERARGS[1]="-geometry 1280x1024"

Finally you must enable the vncserver service which is off by default (Hat menu -> System Settings -> Server Settings -> Sevices). For testing you should either start the service by hand or enable it and reboot your coLinux session.

The VNC session will be available to a VNC viewer as <coLinux-name-or-ip-address>:1

Doing it yourself with xdm on Debian Edit

You need xdm, so install it with:

apt-get install xdm

Afterwards edit /etc/X11/xdm/Xservers, so that it starts a VNC X Server:

:0 local /usr/bin/Xrealvnc :0 -geometry 1280x1024 -depth 32

All other lines Xservers should be commented out.

Afterwards just restart xdm with /etc/init.d/xdm restart.

Using kdm on Debian Edit

kdm should work just as xdm, but it has more features and less documentation :-). I ran into the problem that kdm automatically appends a free virtual terminal number to the xserver command line, vt7 in my case. Adding the option -desktop vt7 to the vnc command line did convince kdm not to do this (and it is harmless). So my line in /etc/kde3/kdm/Xservers to start vnc looks like this:

:0 local /usr/bin/Xvnc4 :0 -geometry 1280x1024 -depth 32 -desktop vt7

You may also try to play with ServerVTs in /etc/kde3/kdm/kderc, removing the setting may also prevent kdm from looking for a free VT.

Doing it yourself on Debian or similar Edit

This technique is not great, and is not elegant, but it works. AS a warning though, remember that the server will be running as root. But if you like, you can create a new user with

adduser <username>

and change the USER setting in the script.

From the terminal, type:

# nano /etc/init.d/vncstart (replace nano with editor of your choice)

Then, enter in what I have below:

#! /bin/sh
export USER="root"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11"
NAME=vncstart
start()
{
    su - $USER -c"vncserver :1"
}
stop()
{
    su - $USER -c"vncserver -clean -kill :1"
}
case "$1" in
    start)
        echo -n "Starting Xvnc: "
        start
        ;;
    stop)
        echo -n "Stopping Xvnc "
        stop
        ;;
    restart)
        echo -n "Restarting Xvnc "
        stop
        start
        ;;
****)
        echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
        exit 1
        ;;
esac
exit 0

Or use the enhanced version with support for multiple X servers:

#! /bin/bash
# Multiple VNC Servers added by Max Gaukler
export USER="root"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/var/run/vncserver"
NAME="vncstart"

#VNCPARAMS: set your parameters here:
VNCPARAMS[1]="-name blahbblahvnc -geometry 800x600"
# uncomment (remove #) for multiple servers:
# VNCPARAMS[2]="-name asjdafjxcd"
# VNCPARAMS[3]="-name asddsfdsf"
# and so on...

start()
{
        for ((num=1; $num <= ${#VNCPARAMS[*]}; num=$num+1));
        do
                su $USER -c "vncserver ${VNCPARAMS[$num]} :$num"
        done
}
stop()
{
        for ((num=1; $num <= ${#VNCPARAMS[*]}; num=$num+1));
        do
                su $USER -c "vncserver -clean -kill :$num"
        done
}
case "$1" in
    start)
        echo -n "Starting Xvnc servers: "
        start
        ;;
    stop)
        echo -n "Stopping Xvnc "
        stop
        ;;
    restart)
        echo -n "Restarting Xvnc "
        stop
        start
        ;;
****)
        echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
        exit 1
        ;;
esac
exit 0

don't forget to then in the terminal run:

# chmod 755 /etc/init.d/vncstart

Since I'm lazy, to get this running under gentoo, of course use:

# rc-update add vncstart default

OR for Debian:

# update-rc.d vncstart defaults 50

OK, time for the very last bit:

# nano /root/.xsession

and enter in:

#!/bin/sh
startkde &

This will start kde when the vncserver is started at boot time. If you like different things started at different VNC screens automatically, use this script as your ~/.vnc/xstartup.sh:

#!/bin/sh
#xstartup.sh (c) Max Gaukler 2005 - Licensed under GPL
function xprepare {
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vnc4config -iconic & # launch clipboard access
x-window-manager &
}
xprepare
case "$DISPLAY" in
":1")
#first display - KDE
startkde&;;
":2")
#secound display - gnome
gnome-session&;;
":3")
#and so on...
xterm&;;
esac

ENJOY! If you need extra help, visit my site at http://www.cahtech.co.uk, and the forums there too at http://www.cahtech.co.uk/apps/bb


MassTranslated on 25 Dec 2004.
MassTranslated on Sun Apr 23 17:37:00 UTC 2006


If you need muiltiple X server for multiple users, you will have to use the following modified file:

#! /bin/sh
# Multiple VNC Servers added by Max Gaukler
# Modified by Alfonso Reyes (07MAY06) to allow multiple servers for multiple users
# Comment the USER assignment because we need multiple users
# export USER="root" 
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/var/run/vncserver"
NAME="vncstart"

#Add all your users:
USER[1]="root"
USER[2]="alreyes"
USER[3]="janet"
# add more as required ...

#VNCPARAMS: set your parameters here:
VNCPARAMS[1]="-name ${USER[1]} -geometry 1024x768"
VNCPARAMS[2]="-name ${USER[2]} -geometry 800x600"
VNCPARAMS[3]="-name ${USER[3]}"
# add more as required ...

start()
{
        for ((num=1; $num <= ${#VNCPARAMS[*]}; num=$num+1));
        do
                # one new environment per user
                export USER=${USER[$num]}
                # some messages
                echo Applying to user: ${USER[$num]}
                echo these parameters: ${VNCPARAMS[$num]}
                # start individual VNC server session for every user
                su ${USER[$num]} -c "vncserver ${VNCPARAMS[$num]} :$num"
        done
}
stop()
{
        for ((num=1; $num <= ${#VNCPARAMS[*]}; num=$num+1));
        do
                # stop the VNC server sessions for all users
                su ${USER[$num]} -c "vncserver -clean -kill :$num"
        done
}
case "$1" in
    start)
        echo -n "Starting Xvnc servers: "
        start
        ;;
    stop)
        echo -n "Stopping Xvnc "
        stop
        ;;
    restart)
        echo -n "Restarting Xvnc "
        stop
        start
        ;;
****)
        echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
        exit 1
        ;;
esac
exit 0

Around Wikia's network

Random Wiki