From owner-freebsd-rc@FreeBSD.ORG Sat Jul 23 15:20:49 2005 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D14B316A41F for ; Sat, 23 Jul 2005 15:20:49 +0000 (GMT) (envelope-from pauls@utdallas.edu) Received: from mail.stovebolt.com (mail.stovebolt.com [66.221.101.248]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8092643D46 for ; Sat, 23 Jul 2005 15:20:49 +0000 (GMT) (envelope-from pauls@utdallas.edu) Received: from [192.168.2.101] (adsl-68-93-60-6.dsl.rcsntx.swbell.net [68.93.60.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.stovebolt.com (Postfix) with ESMTP id 61E093FC37 for ; Sat, 23 Jul 2005 10:20:44 -0500 (CDT) Date: Sat, 23 Jul 2005 10:20:24 -0500 From: Paul Schmehl To: freebsd-rc@freebsd.org Message-ID: <259A02F8B7F426645765EB45@Paul-Schmehls-Computer.local> In-Reply-To: <20050723123349.GB1024@rogue.smit.lan> References: <468B58E789145A1C6885EA66@utd59514.utdallas.edu> <20050721230123. GA19090@odin.ac.hmc.edu> <20 050722004448.GB19090@odin.ac.hmc.edu> <20050723123349.GB1024@rogue.smit.lan> X-Mailer: Mulberry/4.0.0 (Mac OS X) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: Re: New port startup script fails X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Paul Schmehl 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: Sat, 23 Jul 2005 15:20:49 -0000 --On July 23, 2005 3:33:49 PM +0300 Mike Makonnen wrote: > On Thu, Jul 21, 2005 at 05:44:48PM -0700, Brooks Davis wrote: >> >> Looks mostly good. You can use shell default values instead of the test >> -z stuff to set the variables if you want: >> >> sguild_enable=${sguild_enable:-NO} > > The preferred method is: sguild_enable=${sguild_enable-NO} > (note the absence of : ) > > use of ':-' overrides the variable if it's empty or unset, whereas > '-' only overrides if the variable is unset. > Thanks. I made the corrections. The script now works except for one problem. The tk script spawns two child processes, and when you stop the parent, the children don't die. Is there a way to solve that problem? Here's the present script: #!/bin/sh # PROVIDE: sguild # REQUIRE: DAEMON # BEFORE: LOGIN # KEYWORD: FreeBSD shutdown # Add the following lines to /etc/rc.conf to enable sguild: # sguild_enable (bool): Set to YES to enable sguild # Default: NO # sguild_flags (str): Extra flags passed to sguild # Default: -D # sguild_conf (str): Sguild configuration file # Default: /usr/local/etc/sguil-server/sguild.conf # . /etc/rc.subr name="sguild" rcvar=`set_rcvar` command="/usr/local/bin/sguil-server/sguild" pidfile="/var/run/${name}.pid" procname="tclsh8.4" #command_interpreter=yes load_rc_config ${name} sguild_enable=${sguild_enable-NO} sguild_conf=${sguild_conf-/usr/local/etc/sguil-server/sguild.conf} sguild_flags=${sguild_flags--D} [ -n "$sguild_conf" ] && sguild_flags="$sguild_flags -c $sguild_conf" # Hack until run_rc_command() get rid of exit() sguild_stop() { pid=$(check_pidfile ${pidfile} ${procname}) if [ -z ${pid} ]; then echo "${name} not running? (check ${pidfile})." return 1 fi echo "Stopping ${command}." kill -${sig_stop:-TERM} ${pid} [ $? -ne 0 ] && [ -z "$rc_force" ] && return 1 wait_for_pids ${pid} } run_rc_command "$1" Paul Schmehl (pauls@utdallas.edu) Adjunct Information Security Officer University of Texas at Dallas AVIEN Founding Member http://www.utdallas.edu/