From owner-freebsd-rc@freebsd.org Thu May 19 19:21:15 2016 Return-Path: Delivered-To: freebsd-rc@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 F1A55B3F742 for ; Thu, 19 May 2016 19:21:15 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mailhost.stack.nl", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id BEFC116DB for ; Thu, 19 May 2016 19:21:15 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from toad2.stack.nl (toad2.stack.nl [IPv6:2001:610:1108:5010::161]) by mx1.stack.nl (Postfix) with ESMTP id 7B811B8072; Thu, 19 May 2016 21:21:12 +0200 (CEST) Received: by toad2.stack.nl (Postfix, from userid 1677) id 65AF2892E2; Thu, 19 May 2016 21:21:13 +0200 (CEST) Date: Thu, 19 May 2016 21:21:13 +0200 From: Jilles Tjoelker To: Kade Cole Cc: freebsd-rc@freebsd.org Subject: Re: rc startup file questions Message-ID: <20160519192113.GA95432@stack.nl> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 May 2016 19:21:16 -0000 On Fri, Apr 22, 2016 at 10:43:04AM -0500, Kade Cole wrote: > I am working on a new rc file for starting rtty. I have it working for > startup but it is not working for other arguments (status, stop). Part of > the problem I am having is that when rtty starts it calls ttysrv for the > devices you have configured in /usr/local/rtty/dev and starts a process of > ttysrv for each file in /dev. rtty then also creates multiple pid files in > /usr/local/rtty/pid for each service started. It seems that I can not > figure out how to deal with these multiple pid files. If only one process > of ttysrv is started then everything works. If more than one process is > started I get the error "WARNING: no shebang line in" the second pid file. > I was wondering if anyone has any suggestions on how to write a custom > rtty_status or rtty_stop to deal with multiple pid files in a directory. > Thanks for your help. Below is the current rc script I have been trying. > #!/bin/sh > # PROVIDE: rtty > # REQUIRE: DAEMON usb > # BEFORE: LOGIN > # KEYWORD: shutdown > . /etc/rc.subr > name=rtty > rcvar=rtty_enable > command="/usr/local/rtty/bin/startsrv" > procname="/usr/local/rtty/bin/ttysrv" > pidfile="/usr/local/rtty/pid/*" > start_cmd="${name}_start" > rtty_start(){ > echo "starting rtty." > cd /usr/local/rtty/dev > ${command} * > } > load_rc_config $name > run_rc_command "$1" A wildcard in $pidfile seems rather unlikely to work, and the same applies to listing multiple pathnames in it explicitly. You could write your own rtty_status and rtty_stop which will involve duplicating rc.subr code. Alternatively, the thread 'Good example for startup script with multiple "profiles"?' from February 2016 has several examples of multiple-instance daemons by creating a symlink to the startup script for each instance. This will be a bit more work to manage but will reuse rc.subr code normally. Note that some magic is required to leave the options of service(8) that work with all scripts functional (recent versions of the openvpn port have it). -- Jilles Tjoelker