rc script:start_precmd ignored

Hi everyone.

I've installed FreeRADIUS, but it has one small thing about it which causes unexpected complications. It requires (by OpenSSL) tmpdir=/tmp/radiusd to exist for the server to start. Wouldn't be a problem, but I've set clear_tmp_enable="YES" in my /etc/rc.conf, which leaves /tmp clean upon reboot.

No problem, /tmp/radiusd can be created manually without even special permissions... But in order to enable automatic daemon startup on boot I've used the rc.subr(8) variable start_precmd as a recommended way to add extra actions to the rc startup script:
Code:
#blablabla
. /etc/rc.subr

name=radiusd
rcvar=radiusd_enable
load_rc_config $name

command=/usr/local/sbin/radiusd

extra_commands="reload debug"
debug_cmd="radiusd_debug"
required_dirs=`echo ${radiusd_flags} | sed -Ene 's:.*\-[^[:space:]d]*d[[:space:]]*([^[:space
:]]+).*:\1:p'`
required_dirs=${required_dirs:-"/usr/local/etc/raddb"}
required_files="${required_dirs}/radiusd.conf"
radiusd_enable=${radiusd_enable-"NO"}
command_args="&"
[B]start_precmd="${radiusd_prestart}"[/B]

radiusd_debug()
{
    radiusd_flags="-X ${radiusd_flags}"
    run_rc_command start
}

[B]radiusd_prestart()
{
   if [ ! -d /tmp/radiusd ]; then
      /bin/mkdir /tmp/radiusd
   fi
}[/B]

run_rc_command "$1"
My unsophisticated custom code here works fine when invoked by ordinary user (me) and successfully creates /tmp/radiusd, but from the startup script it doesn't create anything. What might be the problem here? One doesnt' need any special permissions to create things in the /tmp dir, and startup scripts are run by root, are they not?
 
... I've used the rc.subr(8) variable start_precmd as a recommended way to add extra actions to the rc startup script...
It would be more proper to say: the only way one can do this successfully. But I was a bit disappointed by the way manual pages handle this matter.

I mean, here is the only mentioning of it in rc.subr(8):
argument_precmd
Shell commands to run just before running
argument_cmd or the default method for
argument. If this returns a non-zero exit
code, the main method is not performed. If the
default method is being executed, this check is
performed after the required_* checks and
process (non-)existence checks.​


I'm by no means new to manual reading, but "shell commands to run just before..." doesn't make it immediately clear to me that those are CUSTOM shell commands sysadmin or porter feels necessary to add to a startup script for some actions that go beyond the capabilities of rc.subr(8) stuff (the stuff that makes the main subject of the man page).

Yes, I know the logic "if you don't know what it is, then more likely than not you don't need this stuff". But one needs to be balanced about it, too, or else we'll end up with the "insider" approach: we know what we're talking about; you don't, so you're not one of us...
It seems to me, then, that some appropriate explicitness might be added to the part of the manual page that deals with what goes "beyond" the standard routines. Some explicit introduction like: "In some situations additional actions may be required in order to start a daemon. Use argument_precmd for such shell commands that must be run just before..." Short, but clear enough to attract one's attention.

As to my OP, we can mark this as SOLVED.​
 
Back
Top