Shell Porting rc script from FreeBSD 6.0 to FreeBSD 10.1

Hi

I am trying to use the rc script [1] (found via [2]) on my FreeBSD 10.1 installation. The script was originally written for FreeBSD 6.0 (that's what it claims, at least).

For some reason the script does not work (when called with the "start" argument). It claims that it "cannot run " (and I think it should indicate what it cannot run but it's empty which is probably the reason why it cannot be run...). Basically saying "I cannot run <nothing>".

From what I understand the script is "constructing" the concrete command in start_precmd. That procedure (?) is never called, it seems. Maybe because rc.subr() "realises" that it does not know what command to execute?

Do I have to have start_cmd set?

I also found another resource [3] talking about the same thing. They have a start_cmd...

Unfortunately I do not seem to understand enough of rc scripting to figure this out.

For example, is there a difference between these two lines (not the colon before the equal sign in the first line)?

Code:
: ${dummy_enable:=no}
: ${dummy_msg="Nothing started."}

This is from [4], section 4, A configurable dummy script.

[1] https://redmine.lighttpd.net/attachments/661/fastcgi-php.2.sh
[2] https://redmine.lighttpd.net/projects/lighttpd/wiki/Fastcgi-php-starter-for-freebsd
[3] https://code.djangoproject.com/ticket/9182
[4] https://www.freebsd.org/doc/en/articles/rc-scripting/article.html
 
I'm not quite certain just what is failing with that script, but I think it might be worth looking at using the www/spawn-fcgi port, instead of using a 10 year old script off the web. That port comes with its own rc script, and it looks like your ancient one from the web just starts spawn-fcgi anyway.
 
That port comes with its own rc script
Oh my god, you are so right. It was there the whole time, sitting right in front of me and I did not see it. THANK YOU!

Out of curiosity: is there a difference between the two ways to set default values in rc scripts (the "colon thing")?
Code:
: ${dummy_enable:=no}
: ${dummy_msg="Nothing started."}
 
From sh(1)
Code:
${parameter:=word}
         Assign Default Values.  If    parameter is unset or null, the    expan-
         sion of word is assigned to parameter.  In    all cases, the final
         value of parameter    is substituted.     Quoting inside    word does not
         prevent field splitting or    pathname expansion.  Only variables,
         not positional parameters or special parameters, can be assigned
         in    this way.

     In    the parameter expansions shown previously, use of the colon in the
     format results in a test for a parameter that is unset or null; omission
     of    the colon results in a test for    a parameter that is only unset.

So, if I understand it correctly, := sets parameter to word if it is either not set or null. With colon omitted, = sets parameter only if it is unset.
 
Out of curiosity: is there a difference between the two ways to set default values in rc scripts (the "colon thing")?
Yes, look at sh(1) section Parameter Expansion:
Code:
${parameter:=word}
     
Assign Default Values.  If parameter is unset or null, the expansion
of word is assigned to parameter.  In all cases, the final value of
parameter is substituted.
             
[...]

In the parameter expansions shown previously, use of the colon in the
format results in a test for a parameter that is unset or null;
[b]omission of the colon results in a test for a parameter that is only
unset[/b].
Example:
Code:
$ cat test.sh                                                        
: ${GREETING:="hi"} 
echo $GREETING
$ sh test.sh
hi
$ env GREETING="hello" sh test.sh
hello
$ env GREETING="" sh test.sh
hi

$ cat test2.sh
: ${GREETING="hi"} 
echo $GREETING
$ sh test2.sh
hi
$ env GREETING="hello" sh test.sh
hello
$ env GREETING="" sh test.sh
The last example returned an empty line because we used = (without the colon) and GREETING was null, so no default value was assigned.
 
Back
Top