Talk:RPi VNC Server

Just a note to say that although this set-up worked beautifully, it meant that I was always VNC'ing in as root. By using su, I could run as any user, e.g.:


 * 1) BEGIN INIT INFO
 * 2) Provides:             vncserver
 * 3) Required-Start:       $remote_fs $syslog
 * 4) Required-Stop:        $remote_fs $syslog
 * 5) Default-Start:        2 3 4 5
 * 6) Default-Stop:         0 1 6
 * 7) Short-Description:    Start VNC Server at boot time
 * 8) Description:          Start VNC Server at boot time
 * 9) END INIT INFO


 * 1) !/bin/sh

export USER=root export HOME=/root export RUN_USER=pi

case "$1" in start)    echo "Starting VNC Server"    su - $RUN_USER -c "/usr/bin/vncserver :1 -geometry 1280x1024 -depth 24"    ;;

stop)   echo "Stopping VNC Server"    su - $RUN_USER -c "/usr/bin/vncserver -kill :1"    ;;

*)   echo "Usage: $0 {start|stop}"    exit 1    ;; esac

exit 0

init scripts should be merged into one
Hi. I think the init scripts on this page should be merged into one, since both of them have some problems and you probably want to run a VNC server as your unprivileged user anyway.

In the first script, you can't simply do this: USER=root HOME=/root

export USER HOME

This page explains why you can't do that.

Overall, the script should look something like this:
 * 1) BEGIN INIT INFO
 * 2) Provides: tightvnc
 * 3) Required-Start: $remote_fs $syslog
 * 4) Required-Stop: $remote_fs $syslog
 * 5) Default-Start: 2 3 4 5
 * 6) Default-Stop: 0 1 6
 * 7) Short-Description: Start VNC Server at boot time
 * 8) Description: Start the Tight VNC Server at boot time.
 * 9) END INIT INFO


 * 1) ! /bin/sh
 * 2) /etc/init.d/tightvnc

USER='pi' # Change your desired user here

case "$1" in start)  #Insert your favoured settings for a VNC session   su $USER -c '/usr/bin/vncserver :0 -geometry 1280x800 -depth 16 -pixelformat rgb565'   echo "Tight VNC server started"   ;;

stop)  pkill Xtightvnc   echo "Tight VNC server stopped"   ;;

restart)  pkill Xtightvnc   #Insert your favoured settings for a VNC session   su $USER -c '/usr/bin/vncserver :0 -geometry 1280x800 -depth 16 -pixelformat rgb565'   echo "Tight VNC server restarted"   ;;

*)  echo "Usage: /etc/init.d/vncboot {start|stop|restart}"   exit 1   ;; esac

exit 0

It's based on both of the scripts on the page, as well as my own experience with init scripts. I've also added a restart option, for well, easy restarting of the server.

Tom Slominski

Link to working script
Both scripts on RPi VNC Server wikipage have problems, but I found this discussion where you can find working script: http://www.raspberrypi.org/phpBB3/viewtopic.php?p=108862

Saamac1 (talk) 08:17, 15 April 2013 (UTC)