Date: Sun, 7 Sep 2014 21:23:22 +0200 From: "O. Hartmann" <ohartman@zedat.fu-berlin.de> To: Scot Hetzel <swhetzel@gmail.com> Cc: FreeBSD CURRENT <freebsd-current@freebsd.org>, FreeBSD Ports <freebsd-ports@freebsd.org>, Erich Dollansky <erich@alogt.com> Subject: Re: service doen't get started at boottime, but can start manually Message-ID: <20140907212322.4f2d370f.ohartman@zedat.fu-berlin.de> In-Reply-To: <CACdU%2Bf8eYF_HbwqOq0RoC4dq_mG1io5LYfafyipzMn-EzVq9xA@mail.gmail.com> References: <20140907090321.12bbc428.ohartman@zedat.fu-berlin.de> <20140907153342.2366ad8b@X220.alogt.com> <20140907094308.6c466d9f.ohartman@zedat.fu-berlin.de> <CACdU%2Bf_%2BB353Hyv2cHir=Jp53MZoKsFeu4i=spDKEAgsjHmcVQ@mail.gmail.com> <CACdU%2Bf_fby%2BKUUWTEDJrcPSdTdYNx=c2-WMG-pP%2BeR8peuXwiQ@mail.gmail.com> <20140907112811.5570fc85.ohartman@zedat.fu-berlin.de> <CACdU%2Bf-w4v_8ebe=VsEJn9f4pu_MGdOfugjeL=Wkpyp6PE=TWg@mail.gmail.com> <CACdU%2Bf8eYF_HbwqOq0RoC4dq_mG1io5LYfafyipzMn-EzVq9xA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Am Sun, 7 Sep 2014 11:16:37 -0500
Scot Hetzel <swhetzel@gmail.com> schrieb:
> On Sun, Sep 7, 2014 at 10:44 AM, Scot Hetzel <swhetzel@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"
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQEcBAEBAgAGBQJUDLCuAAoJEOgBcD7A/5N8aN8IAMbevzPk4U29a0a7PiJgJNKl
Cb7PZEWYi3lkd//tOORJ+F7fKIeKgSj70DY7OoMN3xkF0uoECa6ql28R8Iwb/8w4
e2loMTF4JDxVT5nuMfY7eHD3emI+ru/27OlFhpW9RIOeD+DD7Fs/nLywlxzuebMm
mmZBplY6waqWbS5tL0f97bREi0pAxBRe6Sl1hB/CLNXi71DDkR5q45X8Xo6FaSaR
QTrXKC6tTt4/qDmW3gPOTDqZACZSR7JHjmWrQuwfs6vKKcprz3LLy3/CsDxH6NmO
DnX9Qm9uGPSAhAPg0K56SUGuSxA+WkheI5qz9hRI9YW1TSdLt79xef3ChM7gqEw=
=MqKS
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140907212322.4f2d370f.ohartman>
