Date: Thu, 19 May 2016 21:21:13 +0200 From: Jilles Tjoelker <jilles@stack.nl> To: Kade Cole <kadecole@gmail.com> Cc: freebsd-rc@freebsd.org Subject: Re: rc startup file questions Message-ID: <20160519192113.GA95432@stack.nl> In-Reply-To: <CAOR7%2B3jm3h_z-iXj0KPVFrZQGJ=f3Py3gSbnLzg5eEdt2qQOiw@mail.gmail.com> References: <CAOR7%2B3jm3h_z-iXj0KPVFrZQGJ=f3Py3gSbnLzg5eEdt2qQOiw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160519192113.GA95432>