Re: service doen't get started at boottime, but can start manually
Am Sun, 7 Sep 2014 11:16:37 -0500 Scot Hetzel schrieb: > On Sun, Sep 7, 2014 at 10:44 AM, Scot Hetzel 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. > > > It seems to me, that when a port installs a script appended with "*.sh" in etc/rc.d/, the script gets executed anyway - regardless wether the service is enabled in /etc/rc.conf[.local] or not. This is especially the case for the original port textproc/refdb. The reason why especially one particular machine rejected the startup of the service was: I changed the script's name from refdb.sh to refdb and with the lack of the correct syntax and definitions inside it, the system (11.0 CURRENT) did not start the service while the other systems running refdb used the oldstyle refdb.sh script. Just for the conclusion of the obscure (at least for me) behaviour. Thanks for your time, Oliver signature.asc Description: PGP signature
Re: service doen't get started at boottime, but can start manually
Am Sun, 7 Sep 2014 11:16:37 -0500 Scot Hetzel schrieb: > On Sun, Sep 7, 2014 at 10:44 AM, Scot Hetzel 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" signature.asc Description: PGP signature
Re: service doen't get started at boottime, but can start manually
On Sun, Sep 7, 2014 at 10:44 AM, Scot Hetzel 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. > -- DISCLAIMER: No electrons were maimed while sending this message. Only slightly bruised. ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: service doen't get started at boottime, but can start manually
On Sun, Sep 7, 2014 at 4:28 AM, O. Hartmann wrote: > Am Sun, 7 Sep 2014 04:03:25 -0500 > Scot Hetzel schrieb: > >> On Sun, Sep 7, 2014 at 3:39 AM, Scot Hetzel 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 > /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. ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: service doen't get started at boottime, but can start manually
Am Sun, 7 Sep 2014 04:03:25 -0500 Scot Hetzel schrieb: > On Sun, Sep 7, 2014 at 3:39 AM, Scot Hetzel 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 /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. Oliver signature.asc Description: PGP signature
Re: service doen't get started at boottime, but can start manually
On Sun, Sep 7, 2014 at 3:39 AM, Scot Hetzel 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. -- DISCLAIMER: No electrons were maimed while sending this message. Only slightly bruised. ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: service doen't get started at boottime, but can start manually
On Sun, Sep 7, 2014 at 2:43 AM, O. Hartmann wrote: > Am Sun, 7 Sep 2014 15:33:42 +0800 > Erich Dollansky schrieb: > >> Hi, >> >> On Sun, 7 Sep 2014 09:03:21 +0200 >> "O. Hartmann" wrote: >> >> > >> > I use a service (textprox/refdb from ports, refdb_enable="YES" >> > in /etc/rc.conf.local) that is supposed to startup at boottime. On >> > one CURRENT system, running >> > >> > FreeBSD 11.0-CURRENT #3 r271210: Sat Sep 6 22:39:59 CEST 2014 amd64 >> > >> > the service is not started at boottime, but I can start the service >> > manually via >> > >> > service refdb start >> > >> > I tried enabling rc_debug=YES in /etc/rc.conf but I do not see any >> > failure of the start attempt of that specific service in the logs or >> > on the console. >> > >> > Is there an elegant way to debug rc.d and the startup procedure >> > without having the system reboot (I do not have jails or VM, sorry)? >> > >> could it be that the spelling in either rc.conf and the spelling in the >> actual script differ so that FreeBSD does not start it? >> >> Erich > > No. If it would be the case, I guess starting it manually wouldn't work > either. The fact > is that the port textproc/refdb uses a startup script named "refdb.sh" and by > maintaining > the port and on the way to make it more CURRENT compliant, I started with > renaming it to > "refdb" and it seems this is the culprit. > > The script textproc/refdb uses is a bit awkward since it targets both *BSD > and Linux > init/rc scripts and the initial rc.d/refddb scripts gives control to another > script > called refdbctl which seems to perform all the stuff FreeBSD's /etc/rc.subr > is providing. > > I renamed the script back to "refdb.sh" by now and the service starts again as > expected. I guess the spawning into a subshell fails somehow at that point > when booting > the box. > 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. The following will show you the order that your startup scripts run, refdb may not be listed: rcorder /etc/rc.d/* /usr/local/etc/rc.d/* Some one will have to create a proper rc script by looking at what both scripts/refdb.in and scripts/refdbctl.in do. The reason that you are able to use service to start refdb, is due to service doesn't check the scripts header for the keywords. -- DISCLAIMER: No electrons were maimed while sending this message. Only slightly bruised. ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: service doen't get started at boottime, but can start manually
Am Sun, 7 Sep 2014 15:33:42 +0800 Erich Dollansky schrieb: > Hi, > > On Sun, 7 Sep 2014 09:03:21 +0200 > "O. Hartmann" wrote: > > > > > I use a service (textprox/refdb from ports, refdb_enable="YES" > > in /etc/rc.conf.local) that is supposed to startup at boottime. On > > one CURRENT system, running > > > > FreeBSD 11.0-CURRENT #3 r271210: Sat Sep 6 22:39:59 CEST 2014 amd64 > > > > the service is not started at boottime, but I can start the service > > manually via > > > > service refdb start > > > > I tried enabling rc_debug=YES in /etc/rc.conf but I do not see any > > failure of the start attempt of that specific service in the logs or > > on the console. > > > > Is there an elegant way to debug rc.d and the startup procedure > > without having the system reboot (I do not have jails or VM, sorry)? > > > could it be that the spelling in either rc.conf and the spelling in the > actual script differ so that FreeBSD does not start it? > > Erich No. If it would be the case, I guess starting it manually wouldn't work either. The fact is that the port textproc/refdb uses a startup script named "refdb.sh" and by maintaining the port and on the way to make it more CURRENT compliant, I started with renaming it to "refdb" and it seems this is the culprit. The script textproc/refdb uses is a bit awkward since it targets both *BSD and Linux init/rc scripts and the initial rc.d/refddb scripts gives control to another script called refdbctl which seems to perform all the stuff FreeBSD's /etc/rc.subr is providing. I renamed the script back to "refdb.sh" by now and the service starts again as expected. I guess the spawning into a subshell fails somehow at that point when booting the box. Oliver signature.asc Description: PGP signature