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

From: O. Hartmann <ohartman_at_zedat.fu-berlin.de>
Date: Sun, 7 Sep 2014 21:23:22 +0200
Am Sun, 7 Sep 2014 11:16:37 -0500
Scot Hetzel <swhetzel_at_gmail.com> schrieb:

> On Sun, Sep 7, 2014 at 10:44 AM, Scot Hetzel <swhetzel_at_gmail.com> wrote:
> > 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"
> 
> I missed required_files in my editing of the original script.
> 
> If refdbd does have a configuration file, changes this to point to the
> correct file, otherwise this can be removed.
> 
> > 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.
> >
> 

Scot,

I already have a initial refdbd frameworked file, thanks for your considerations.

I think the following code is suitable for a clean FreeBSD-style rc.d file for the port.
I managed it to restart, status and start/stop via this rc.d-init script and it is for
the upcoming refdb-1.0.3 which is in preparation.

I need to mimik the refdbctl code at the point where it is looking for the configuration
of the PID file via refdbdrc in %%PREFIX%%/etc/refdb/. I havn't tested the code properly,
yet, but it worked as far a I could test it.

Regards,
Oliver Hartmann


[...]
#!/bin/sh
#
# $FreeBSD$
#
# O. Hartmann, Berlin, 2014
#
#
# PROVIDE: refdbd
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# To enable this service, place
#
# refdbd_enable="YES"
#
# in /etc/rc.conf[.local]
# 
# and optionally set the the following variables upon your environment:
#
# Choose another PIDFILE as the configured and/or default one:
# refdbd_pidfile="/var/run/refdbd.pid"
#
# To make the refdbd daemon accessible local only (127.0.0.1):
# refdbd_local="YES"

. /etc/rc.subr

name="refdbd"
rcvar=refdbd_enable

# read settings, set defaults
load_rc_config ${name}

command="%%PREFIX%%/bin/${name}"
globalconfig="%%PREFIX%%/etc/refdb/refdbdrc"
pidfile="/var/run/${name}.pid"
extra_commands="reload"

load_rc_config ${name}

: ${refdbd_enable:="NO"}
: ${refdbd_local:="NO"}

if checkyesno refdbd_local; then
  refdbd_local_flags="-I"
else
  refdbd_local_flags=""
fi

start_precmd="${name}_prestart"

refdbd_prestart()
{
        local   refdbvar refdbval

        # Check whether we have configured a PID file
        if [ "x${refdbd_pidfile}" != "x" ]; then
                pidfile="${refdbd_pidfile}"

        # ... if not configured via rc.conf[.local],
        # read the settings in the configure file. We're only interested in
        # nonstandard PID file settings
        else
                for config in ${globalconfig}; do
                        while read refdbvar refdbval; do
                                if [ -n "${refdbvar}" ]; then
                                        if [ ${refdbvar}="pidfile" ]; then
                                                pidfile=${refdbval}
                                        fi
                                fi
                        done < $config
                done
        fi

        piddir=`dirname ${pidfile}`
        mkdir -p ${piddir}

        refdbd_pid_flags="-P ${pidfile}"
}

# Set command arguments upon configuration
command_args="${refdbd_local_flags} ${refdbd_pid_flags}"

run_rc_command "$1"


Received on Sun Sep 07 2014 - 17:23:36 UTC

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