Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 May 2005 14:04:36 +0200
From:      Peter van Swieten <swieten@itsef.com>
To:        freebsd-rc@freebsd.org, freebsd-questions@freebsd.org
Subject:   Strange behaviour of my script within /etc/rc.d
Message-ID:  <42931854.1010804@itsef.com>

next in thread | raw e-mail | index | archive | help
Hi,

While trying to get my script within the /etc/rc.d tree operational I 
ran into some strange behaviour.

I intended to start a vncserver as part of the boot process. I build the 
script based on several existing scripts (a.o. the apache script). The 
script works as expected when run from the command line in a operational 
FreeBSD system. During boot however it does not.

Probem description:
To be more specific it looks like the construction with the default 
value of a variable defined in the script and possibly being overridden 
in rc.conf DOES NOT WORK WHILE BOOTING.

Note that since this is my first rc.d script, I might as well be doing 
something wrong, nevertheless the operation of the script works 
different in the two modes.

Remark: I realize that there is a separate mailing list for rc.d things. 
The website for it however does not show any messages (but then maybe 
there are none). For this reason I post this message to both the general 
questions and the rc mailing list.

Some details:
-----------------------------------------------------------------------------------------------------------------
I recently installed this system from the 5.3 ISO. As far as I know 
nothing was changed to the rc.d part.
uname -a output:
FreeBSD peter-test-vm1.itsef.com 5.3-RELEASE FreeBSD 5.3-RELEASE #0: Fri 
Nov  5 04:19:18 UTC 2004     
root@harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
-----------------------------------------------------------------------------------------------------------------
rc.conf:
...
# To start vncserver on startup:
vncserver_enable="YES"
vncserver_user="swieten"
vncserver_display=":0"
...
-----------------------------------------------------------------------------------------------------------------
my script:
#!/bin/sh

# PROVIDE: vncserver
# This scripts starts vncserver running as user [vncserver_user] at 
[vncserver_display]
# Author: PvSwieten

# Define these vncserver_* variables in one of these files:
#       /etc/rc.conf
#       /etc/rc.conf.local
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
vncserver_enable="NO"
vncserver_user="root"
vncserver_display=":0"

. /etc/rc.subr

name="vncserver"
rcvar=`set_rcvar`

start_cmd="vncserver_start"
stop_cmd="vncserver_stop"


vncserver_start()
{
        su -l ${vncserver_user} -c "/usr/local/bin/vncserver -geometry 
1152x864 $vncserver_display"
}

vncserver_stop()
{
        su -l ${vncserver_user} -c "/usr/local/bin/vncserver -kill 
${vncserver_display}"
}

load_rc_config $name
run_rc_command "$1"
-----------------------------------------------------------------------------------------------------------------

-- 
--------------------------------------------------------
Peter van Swieten            Tel +31 15 2692533
TNO-ITSEF BV                 Fax +31 15 2692555
Delftechpark 1               http://www.itsef.com
2628 XJ Delft                swieten@itsef.com
The Netherlands




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?42931854.1010804>