nadir
Posts: 112
Joined: Sun Jun 10, 2012 5:45 am

autostart vnc-server

Thu Sep 27, 2012 4:44 pm

I searched, but can't find the answer.
How do i autostart a vnc-server (probably xtigthvncserver) during boot?
I also would like to run
modprobe snd_bcm2835
automatically.

I found for example this:
http://elinux.org/RPi_Wheezy_VNC
and also searched for rc.local in the wiki. But i can't find a clear advice.

Thanks.

User avatar
malakai
Posts: 1382
Joined: Sat Sep 15, 2012 10:35 am

Re: autostart vnc-server

Thu Sep 27, 2012 5:08 pm

My preferred way is as follows

On your PC, go to http://sourceforge.net/projects/xming/ and download the latest version of Xming. Install this with all the default settings.

At this point, Xming is all ready to go. However, there are some configurations options you might like:

Xming Configuration

Xming shortcut needs some options.

Right click on your shortcut and click Properties.
Select the ‘Shortcut’ tab
In the ‘Target:’ textbox, there will be the path of the Xming.exe followed by a number of options.

"C:\Program Files (x86)\Xming\Xming.exe" :0 -clipboard -rootless

MAKE SURE THE SHORT CUT HAS THESE SETTINGS

Xming.exe" :0 -clipboard -rootless

Run xming

Run PuTTY.
Select SSH as the connection type.
Enter in your Pi's IP address as the Host Name
The port should be 22 unless you know better
In PuTTY’s option tree, select Connection/SSH/X11
Check the box labelled Enable X11 forwarding
Go back to Session options (in the option tree)
If you would like to save these settings, type a name in the Saved Sessions box and click Save
Click Open


Once you have logged in, type startlxde
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)

nadir
Posts: 112
Joined: Sun Jun 10, 2012 5:45 am

Re: autostart vnc-server

Thu Sep 27, 2012 5:18 pm

To make a long story short: I don't use Windows.

What i try is to avoid to first have to use ssh, but start vnc and use it in the first place.

Thanks for your ideas.

Lirex
Posts: 16
Joined: Sat Jul 14, 2012 2:18 pm

Re: autostart vnc-server

Thu Sep 27, 2012 5:26 pm

1.sudo apt-get install tightvncserver
2.vncpsswd
3.sudo nano /etc/init.d/vncserver

Code: Select all

#!/bin/sh
#
# /etc/init.d/vncserver                 this Script
# /usr/bin/vncserver                    Program
#
### BEGIN INIT INFO
# Provides:          tightvncserver
# Required-Start:    $syslog
# Required-Stop:     $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: vnc server
# Description:
#
### END INIT INFO
# Check for missing binaries
FOO_BIN=/usr/bin/vncserver
test -x $FOO_BIN || exit 5

# User under which the VNC server will be executed
VNC_USER=""
export VNC_USER

# Set HOME of User
HOME=""
export HOME

# Set ID for Connections
FOO_ID=1

case "$1" in
    start)
        echo -n "Starting Vnc-Server with Terminal-ID $FOO_ID "

        # Delete old PIDs
        rm -f $HOME/.vnc/$HOSTNAME:$FOO_ID.pid

        if [ -e $HOME/.vnc/$HOSTNAME:$FOO_ID.log ]; then
           cat $HOME/.vnc/$HOSTNAME:$FOO_ID.log >> /var/log/vncserver.log 2>&1
           rm -f $HOME/.vnc/$HOSTNAME:$FOO_ID.log
        fi

        sudo -u $VNC_USER -H $FOO_BIN :$FOO_ID 2>&1
        ;;
#
     stop)
        echo -n "Shutting down Vnc-Server "
        $FOO_BIN -kill :$FOO_ID 2>&1

        cat $HOME/.vnc/$HOSTNAME:$FOO_ID.log >> /var/log/vncserver.log 2>&1
        rm -f $HOME/.vnc/$HOSTNAME:$FOO_ID.log

        ;;
#
     restart)
        $0 stop
        $0 start
        ;;
#
    *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
        ;;
esac
The variable VNC_USER determined executed users HOME determines under which directory the logs and configuration of the VNC server are stored and FOO_ID determines the terminal ID of the VNC server. These variables need to be adjusted to your own preferences yet.
4.sudo chmod +x /etc/init.d/vncserver
5.sudo chown root:root /etc/init.d/vncserver
6.sudo chmod 0755 /etc/init.d/vncserver
7.sudo update-rc.d vncserver defaults
With the client can then access the server through ipadress_server: 5901

Lirex

nadir
Posts: 112
Joined: Sun Jun 10, 2012 5:45 am

Re: autostart vnc-server

Thu Sep 27, 2012 7:23 pm

Thanks.
First remmina, the vnc-client i use, gave me an error: "Can't connect to vncserver".
I did "ls -l /usr/bin/vncserver", which is a link to /etc/alternatives/vncserver. I looked at the script, couldn't find "tightvncserver" in it, and replaced "/usr/bin/vncserver" with /usr/bin/tightvncserver" in /etc/init.d/vncserver.

drakongetes
Posts: 5
Joined: Mon May 20, 2013 6:15 pm

Re: autostart vnc-server

Mon May 20, 2013 11:24 pm

hi Lirex,

thanks for post - very useful.

However, I would like to control the size of the VNC window.
When I start VNC manually, I use:
tightvncserver :1 -geometry 1920x1080.
Now I tried to add this command to the vncserver config file, but no luck

FOO_BIN=/usr/bin/vncserver -geometry 1920x1080
test -x $FOO_BIN || exit 5

also tried:
FOO_BIN=/usr/bin/vncserver :1 -geometry 1920x1080
test -x $FOO_BIN || exit 5


Any thoughts?
thank you in advance.

Return to “Raspberry Pi OS”