On 12 September 2012 21:45, Jenny Hopkins hopkins.jenny@gmail.com wrote:
On 12 September 2012 20:54, John Woodard mail@johnwoodard.co.uk wrote:
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
I like your little function trick probably neater than what I've ended up with which is this script as /etc/init.d/tightvncserver
#!/bin/sh -e ### BEGIN INIT INFO # Provides: tightvncserver # Required-Start: networking # Default-Start: 2 3 4 5 # Default-Stop: 0 6 ### END INIT INFO
PATH="$PATH:/usr/bin/"
# The Username:Group that will run VNC export USER="pi" #${RUNAS}
# The display that VNC will use DISPLAY="1"
# Color depth (between 8 and 32) DEPTH="16"
# The Desktop geometry to use. #GEOMETRY="<WIDTH>x<HEIGHT>" #GEOMETRY="800x600" #GEOMETRY="1024x768" GEOMETRY="1280x1024"
# The name that the VNC Desktop will have. NAME="my-vnc-server"
OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
. /lib/lsb/init-functions
case "$1" in start) log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}" su ${USER} -c "/usr/bin/tightvncserver ${OPTIONS}" ;;
stop) log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}" su ${USER} -c "/usr/bin/tightvncserver -kill :${DISPLAY}" ;;
restart) $0 stop $0 start ;; esac
exit 0
It runs at any run level as the std user "pi" and does the job. I don't think {NAME} is strictly necessary but the {GEOMETRY}, {DEPTH} are needed and the {DISPLAY} vital. I did try with the options right after the command as you would input in command line [command:display# -option foo -option2 bar] but it didn't work? Is BASH that way inclined?
All working now.
Cheers, BJ