New port startup script fails

Paul Schmehl pauls at utdallas.edu
Sat Jul 23 15:20:49 GMT 2005


--On July 23, 2005 3:33:49 PM +0300 Mike Makonnen <mtm at 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 at utdallas.edu)
Adjunct Information Security Officer
University of Texas at Dallas
AVIEN Founding Member
http://www.utdallas.edu/


More information about the freebsd-rc mailing list