From owner-freebsd-questions@FreeBSD.ORG Sun Sep 2 10:22:32 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2FC6B16A417 for ; Sun, 2 Sep 2007 10:22:32 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from snoogles.rachie.is-a-geek.net (66-230-99-27-cdsl-rb1.nwc.acsalaska.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id E726513C459 for ; Sun, 2 Sep 2007 10:22:31 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from localhost (localhost [127.0.0.1]) by snoogles.rachie.is-a-geek.net (Postfix) with ESMTP id 329711CC38 for ; Sun, 2 Sep 2007 02:21:56 -0800 (AKDT) From: Mel To: freebsd-questions@freebsd.org Date: Sun, 2 Sep 2007 12:21:53 +0200 User-Agent: KMail/1.9.7 References: <80f4f2b20709012017m181fe312s14f7d4f60f9ba295@mail.gmail.com> In-Reply-To: <80f4f2b20709012017m181fe312s14f7d4f60f9ba295@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200709021221.54268.fbsd.questions@rachie.is-a-geek.net> Subject: Re: problems with a rc.d script I'm creating X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Sep 2007 10:22:32 -0000 On Sunday 02 September 2007 05:17:08 Jim Stapleton wrote: > I'm trying to create an rc.d script to start akpop3d (it doesn't seem > to come with one). > > According to the documentation on run_rc_command in /etc/rc.subr, I > thought this should work. However I get no response when I run > '/usr/local/etc/rc.d/akpop3d start', and ps -A doesn't show an akpop3d > process. When I run it manually (akpop3d -d -s -L .akpop3d), it starts > just fine. > > Could anyone suggest what I am missing here? > > Thanks, > -Jim Stapleton > > The script: > > #!/bin/sh > # > # $FreeBSD: N/A > # > # PROVIDE: akpop3d > # REQUIRE: DAEMON > # > # Add the following line to /etc/rc.conf to enable akpop3d: > # > # akpop3d_enable="YES" > # > > > akpop3d_enable=${akpop3d_enable-"NO"} > akpop3d_pidfile=${akpop3d_pidfile-"/var/run/akpop3d.pid"} > akpop3d_flags=${akpop3d_flags-"-d -s -L .akpop3d"} > akpop3d_conffile=${akpop3d_conffile-""} > akpop3d_flush_cache=${akpop3d_flush_cache-"NO"} > > . /etc/rc.subr > > > if [ ! -z $(check_pidfile $akpop3d_pidfile akpop3d) ] > then > > else > > fi > > name=akpop3d > rcvar=`set_rcvar` > > command=/usr/local/bin/${name} > pidfile=${akpop3d_pidfile} > #start_precmd=akpop3d_precmd > > load_rc_config ${name} > > > > run_rc_command "$1" I haven't figured out the proper way myself, but the problem is that the defaults you set at top, override the rc.conf variables, because they don't exist yet. What I do is move load_rc_config before setting defaults. General order becomes: name=foo rcvar=`set_rcvar` load_rc_config ${name} foo_default=${foo_default:-"default value"} run_rc_command "$1" Seems to work, maybe I'll figure out the proper way once I finish reading: http://www.freebsd.org/doc/en_US.ISO8859-1/articles/rc-scripting/index.html -- Mel People using reply to all on lists, must think I need 2 copies.