Simple startup script for TightVNC (error)

This is my first script and when I run it from shell with /usr/local/etc/rc.d/vnc onestart/onestop it works perfectly.

But when the system boots up doesn't work. If I run with start I get the next error:
Code:
Cannot 'start' vnc. Set set_rcvar to YES in /etc/rc.conf or use 'onestart' instead of 'start'

I've added vnc_enable="YES" to /etc/rc.conf. I was reading the Handbook about rc scripts but I didn't find the solution. I try changing the line with rcvar with other options that I found in other rc scripts but I get the same problem. Here my script
Code:
#!/bin/sh

. /etc/rc.subr

name="vnc"
vnc_display=":1"
vnc_options="-name Sesion1VNC -depth 16 -geometry 1024x768 -compatiblekbd -fp '/usr/local/lib/X11/fonts/misc,/usr/local/lib/X11/fonts/75dpi/,/usr/local/lib/X11/fonts/100dpi/'"
rcvar='set_rcvar'
start_cmd="${name}_start"
stop_cmd="${name}_stop"
load_rc_config $name
eval "${rcvar}=\${${rcvar}-'NO'}"
vnc_msg=${vnc_msg:-"Iniciando servidor VNC ..."}

vnc_start(){
	echo "$vnc_msg"
	su Carleos -c "PATH=$PATH:/home/Carleos"
	su Carleos -c "vncserver ${vnc_display} ${vnc_options}"
}

vnc_stop () {
	echo -n $"Cerrando servidor VNC ...  "
	su Carleos -c "vncserver -kill :1"
}

run_rc_command "$1"
 
I'd expect something like:
Code:
vnc_enable="${vnc_enable-NO}"
in there, and
Code:
rcvar=`set_rcvar`
requires backticks (you appear to use quotes).
 
The error was for quotes (I'll never think about it). Typical things with new language script/programming...

Now it works perfectly with start/stop/restart/onestart/onestop with my line
Code:
eval "${rcvar}=\${${rcvar}-'NO'}"
and with yours 
vnc_enable="${vnc_enable-NO}"

But it doesn't run at startup with noone of them. I have no idea why.

Thanks.
 
Well, all I can say is study the rc scripts in /usr/local/etc/rc.d/, apply rc(8), and try to emulate them as closely as possible
 
Back
Top