From owner-freebsd-questions@freebsd.org Wed Nov 8 14:23:29 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4AF0AE54E1F for ; Wed, 8 Nov 2017 14:23:29 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from sola.nimnet.asn.au (paqi.nimnet.asn.au [115.70.110.159]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BFCCC7CBC1 for ; Wed, 8 Nov 2017 14:23:27 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from localhost (localhost [127.0.0.1]) by sola.nimnet.asn.au (8.14.2/8.14.2) with ESMTP id vA8ENMNv017487; Thu, 9 Nov 2017 01:23:22 +1100 (EST) (envelope-from smithi@nimnet.asn.au) Date: Thu, 9 Nov 2017 01:23:22 +1100 (EST) From: Ian Smith To: Ernie Luzar cc: freebsd-questions@freebsd.org Subject: Re: Need help with rc.d script In-Reply-To: <5A01F758.1050706@gmail.com> Message-ID: <20171109005843.E72828@sola.nimnet.asn.au> References: <20171108021900.W9710@sola.nimnet.asn.au> <20171108043726.N72828@sola.nimnet.asn.au> <5A01F758.1050706@gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Nov 2017 14:23:29 -0000 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