Talk:RPi VNC Server

From eLinux.org
Revision as of 21:27, 3 July 2012 by Alunwcom (Talk | contribs) (running vnc service as non-root user)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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.:

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

#!/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