Need help with rc.d script
Edgar Pettijohn
edgar at pettijohn-web.com
Thu Nov 9 01:43:07 UTC 2017
On Wed, Nov 08, 2017 at 11:37:37AM -0500, Ernie Luzar wrote:
> Ian Smith wrote:
> > On Tue, 7 Nov 2017 13:11:36 -0500, Ernie Luzar wrote:
> >
> > > Thanks Ian,
> > > Ending the while loop with "done &" worked.
> >
> > The one with or without the enclosing ( and ) to force a subshell?
> >
> > > When I issue dynip from the command line it runs as a daemon but I have to
> > > use the kill command to stop it.
> > >
> > > This is my rc.d script for dynip script. issuing "service dynip start" works
> > > but "service dynip stop" gives message saying
> > > dynip not running? (Check /var/run/dynip.pid). Well ps ax shows it is running
> > > and I have to use the kill command to stop it.
> >
> > Things to check:
> >
> > . after 'start' does /var/run/dynip.pid exist while it's running??
> > . if so, does it contain the same PID as 'ps ax' shows for dynip?
> > . does 'ps ax' show a different PID for the subshell, if there is one?
> > . Does /var/run/dynip.pid still exist after running 'stop'?
> >
> > i.e. is the PID needed for kill the same as that in /var/run/dynip.pid?
> >
> > > Here is my rc.d script. What am I missing to populate the dynip.pid file so
> > > "service dynip stop" command will work?
> > >
> > > #!/bin/sh
> > > #
> > > #
> > > # PROVIDE: dynip
> > > # REQUIRE: LOGIN
> > > # KEYWORD: nojail shutdown
> > > #
> > > # Add the following line to /etc/rc.conf to enable dynip:
> > > #
> > > # dynip_enable="YES"
> > > #
> > >
> > > . /etc/rc.subr
> > > name="dynip"
> > > rcvar=dynip_enable
> > > command="/usr/local/sbin/${name}"
> > > pidfile="/var/run/${name}.pid"
> > > load_rc_config ${name}
> > > run_rc_command "$1"
> >
> > I've very little knowledge of the detailed behaviour of the rc system.
> > Let's see how the above questions might inform before speculating ..
> >
> > cheers, Ian
> >
>
> I tested with and without the enclosing ( and ) on the while loop and it
> made no difference. No pidfile exists before the "service dynip start"
> is issued and non exists afterwards.
>
I don't believe the rc system can write a pidfile for you. Most of if not all
of the services being started by the rc system are written in c and take care
of writing their own pidfile. I suspect you could overcome this by writing a c
program that does so and executes your script every 10 minutes. Or some form of
pgrep perhaps.
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
More information about the freebsd-questions
mailing list