rc scripts

David Allen the.real.david.allen at gmail.com
Mon Jun 30 11:01:31 UTC 2008


On 6/27/08, Paul Schmehl <pschmehl_lists at tx.rr.com> wrote:
> --On Friday, June 27, 2008 14:11:55 -0700 David Allen
> <the.real.david.allen at gmail.com> wrote:
>
>> I need to an '-s' flag to the execution of openntpd's rc script:
>>
>>    # PROVIDE: openntpd
>>    # REQUIRE: DAEMON
>>    # BEFORE:  LOGIN
>>    # KEYWORD: nojail
>>
>>    . /etc/rc.subr
>>
>>    name=openntpd
>>    rcvar=`set_rcvar`
>>    command=/usr/local/sbin/ntpd
>>    required_files=/usr/local/etc/ntpd.conf
>>    openntpd_enable=${openntpd_enable:-"NO"}
>>    load_rc_config $name
>>    run_rc_command "$1"
>>
>> The problems I'm having are multiple.  First, the program doesn't offer
>> any logging, and running it with the "do not daemonize" switch with
>>
>>    # /usr/local/sbin/ntpd -d 2>&1 > logfile
>>
>> yields no output.
>>
>> Then, I'm not sure I understand everything I'm reading in rc.subr(8), but
>> from trial error, I've discovered that modifying the script's "command"
>> variable doesn't work, nor does adding the usual "scriptname_flags"
>> directive to /etc/rc.conf.
>
> Scriptname_flags doesn't work because the port maintainer didn't write the
> startup script so that it parses rc.conf for variables.  You can edit the
> script like this:
>
> command_args="-s"
>
> When rc.subr runs scripts, it runs them like this:
>
> ${command} ${command_args} ${command_flags}
>
> Or you can add this to the startup script and then use flags in rc.conf:
> load_rc_config openntpd
>
> openntpd_flags=${openntpd_flags:-""}
>
> (In that order.)
>
> Then place openntpd_flags="-s" in rc.conf.
>
> Just remember that every time the port is updated, your changes will be
> overwritten, so you'll need to make a backup or leave a note to yourself
> somewhere so you remember to alter the new script.

Thanks for that explanation.

I've since discovered that the "sync on start" doesn't really work (at
least in the same time frame that ntpd does) anyway, so I'll have to
resort to running 'ntpd -gq' at system startup, and then run OpenBSD's
ntpd daemon after the fact.

At least I've something about the rc system.


More information about the freebsd-questions mailing list