On 12 September 2012 20:54, John Woodard mail@johnwoodard.co.uk wrote:
On 12 September 2012 19:23, Jenny Hopkins hopkins.jenny@gmail.com wrote:
On 12 September 2012 11:18, John Woodard mail@johnwoodard.co.uk wrote:
I want to run a vnc server on startup as a user rather than root and seek opinion to where the best place to put the command
tightvncserver :1 -geometry 1280x1024 -depth 16 -pixelformat rgb565
etc/rc.local cron job?
Not sure here really if it needs to be before login so thought it prudent to run as a user.
How about putting a file in /etc/rc2.d/ called S99vncservers_up, adding it to init.d with update-rc.d, the file comprising of something along the lines of:
#####
#!/bin/sh
BINFILE=/usr/bin/vncserver
# bail out gracefully if the package has been removed if [ ! -f $BINFILE ]; then exit 0 fi
vncserver_up() { echo "Starting vncserver for $1" if su $1 --command=$BINFILE then echo "vncserver started ok for user $1" fi }
vncserver_up jenny vncserver_up john
####
Works for me! Jenny
I ended up writing this bash script and bunged it in /etc/init.d as tightvncserver
# !/bin/bash # /etc/init.d/tightvncserver # Carry out specific functions when asked to by the system case "$1" in start) su pi -c '/usr/bin/tightvncserver :1 -geometry 1280x1024 -depth 16 -pix$ echo "Starting VNC server " ;; stop) pkill tightvnc echo "VNC Server has been stopped (didn't double check though)" ;; *) echo "Usage: /etc/init.d/tightvncserver {start|stop}" exit 1 ;; esac
I was being lazy my bash scripting ain't that good but it's now working but not as intended as I'm getting roots desktop. I'll give your solution a go Jen will it run as normal user?
Thanks all.
BJ
The way round that is to make starting the vnc server part a little function, as in vncserverup() { blah } then underneath it call the function with vncserver_up john
which runs the function, passes the name john to the function as variable $1, and so runs the vnc server command as john. su $1 --command=$BINFILE ($1 is interpreted by the function as john)
Jen