Re: service doen't get started at boottime, but can start manually

From: Scot Hetzel <swhetzel_at_gmail.com>
Date: Sun, 7 Sep 2014 10:44:26 -0500
On Sun, Sep 7, 2014 at 4:28 AM, O. Hartmann <ohartman_at_zedat.fu-berlin.de> wrote:
> Am Sun, 7 Sep 2014 04:03:25 -0500
> Scot Hetzel <swhetzel_at_gmail.com> schrieb:
>
>> On Sun, Sep 7, 2014 at 3:39 AM, Scot Hetzel <swhetzel_at_gmail.com> wrote:
>> > I had a look at scripts/refdb.in, it is not a proper rc script for
>> > FreeBSD, as it is missing several keywords:
>> >
>> > # PROVIDE: <- all scripts need this
>> > # REQUIRE:
>> > # BEFORE:
>> > # KEYWORD: <- optional
>> >
>> > Which tells rcorder where to put refdb in the startup order.  Since
>> > these are missing, rcorder doesn't place it in the startup list.
>> >
>> I looked again, and it is not rcorder, it's /etc/rc and /etc/rc.subr
>> that determine which script to run.
>>
>> /etc/rc calls find_local_scripts_new from /etc/rc.subr.
>> find_local_scripts_new checks each rc script to make sure that they
>> have at least a "# PROVIDE: " keyword.  If it does, then it adds that
>> script to ${local_rc}.  Then /etc/rc runs:
>>
>> files=`rcorder /etc/rc.d/* ${local_rc}`
>>
>> to get the startup order for these scripts.  Then /etc/rc starts the
>> scripts in the proper order.
>>
>> Since, /usr/local/etc/rc.d/refdb{,.sh.dist} is missing the "# PROVIDE:
>> ", the script is skipped on startup.
>>
>> Since, rc.d/refdb is not a proper rc script, adding refdb_enable=YES
>> to /etc/rc.conf{,.local} will not control the starting of this script.
>>
>> Someone should fix service, so that it checks the rc script has a "#
>> PROVIDE: ", and displays an error message if it doesn't.
>
> Hello Scott,
>
> as the new maintainer of this port, I'm working on a solution, but first, I have to
> understand the way this obscure rc-script system works. Thanks for your good explanation.
> I tried to put PROVIDE/REQUIRE in the script, but I also changed refdb.sh -> refdb
> which, in the end, didn't work. The service IS started with refdb.sh in rc.d/.
>
> Since the original refdb.sh init script targets both Linux and *BSD and delegates the
> starting, stopping et cetera to a script called refdbctl, the latter script needs to be
> examinded and as far as I understand, most of its functionality is covered
> by /etc/rc.cubr, except the part where refdbctl searches for the path of the PID file and
> replaces the init/default path its configuration counterpart found in
> <prefix>/etc/refdb/refdbdrc.
>
> I guess, at the end FreeBSD doen't need the templated refdbctl/refdb.in (to be found in
> the sources in scripts/).
>
> If you'd like to have a look at it, I can send you the sekelton I've already prepared for
> the refurbishment of the port.
>

I created the rc.d/refdbd script by copying /etc/rc.d/inetd and make a
few minor changes.
This script (untested) should do what the scripts/refdb.in and
scripts/refdbctl.in were doing:

#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: refdbd
# REQUIRE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name="refdbd"
rcvar="refdbd_enable"
command="%%PREFIX%%/bin/${name}"
pidfile="/var/run/${name}.pid"
required_files="/etc/${name}.conf"
extra_commands="reload"

load_rc_config $name
run_rc_command "$1"

Place the above in textproc/refdb/files/refdb.in, then add:

USE_RC_SUBR= refdbd

in textproc/refdb/Makefile.


-- 
DISCLAIMER:

No electrons were maimed while sending this message. Only slightly bruised.
Received on Sun Sep 07 2014 - 13:44:27 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:51 UTC