Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Jul 2005 10:20:24 -0500
From:      Paul Schmehl <pauls@utdallas.edu>
To:        freebsd-rc@freebsd.org
Subject:   Re: New port startup script fails
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> <B858D08121B1B491F0217584@utd59514.utdallas.edu> <20	050722004448.GB19090@odin.ac.hmc.edu> <20050723123349.GB1024@rogue.smit.lan>

next in thread | previous in thread | raw e-mail | index | archive | help

--On July 23, 2005 3:33:49 PM +0300 Mike Makonnen <mtm@identd.net> 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/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?259A02F8B7F426645765EB45>