Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Dec 2012 20:01:09 +0000
From:      Chris Rees <utisoft@gmail.com>
To:        Paul Schmehl <pschmehl_lists@tx.rr.com>
Cc:        freebsd-rc@freebsd.org
Subject:   Re: Need a clue about overriding default methods
Message-ID:  <CADLo83-Zmt3_KSS3FPM5%2BYnZNrAFqkVV8sGNzKO0EyD8ChJP%2Bw@mail.gmail.com>
In-Reply-To: <6B03BFD5116AADF7BFE21262@utd71538.campus.ad.utdallas.edu>
References:  <6B03BFD5116AADF7BFE21262@utd71538.campus.ad.utdallas.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On 19 Dec 2012 17:19, "Paul Schmehl" <pschmehl_lists@tx.rr.com> wrote:
>
> I'm working on an rc.d init script for a port, and I am clearly in need
of a clue.
>
> start, stop and status are not discriminating enough.  This is a tcl
script, so if I don't use procname="/usr/local/bin/tclsh85", rc.subr can't
tell if the daemon is running or not.  If I do use procname, it will kill
*all* daemons running with tclsh.
>
> So I need to divert status and stop to make sure they are discriminating
enough to only check for *this* daemon and only kill *this* daemon.
>
> Here's the relevant bits of my script:
>
> stop_cmd="${name}_stop()"
> status_cmd="${name}_status()"
> rc_pid=`ps -auxw | grep tclsh | grep pcap_agent | awk '{print $2}'`
>
> ${name}_status()
> {
>        if [ -n ${rc_pid} ]; then
>                echo "${name} is running: ${rc_pid}"
>        else
>                echo "${name} not running?"
>        fi
> }
> ${name}_stop()
> {
>        echo "Testing"
>        rc_pid=`ps -auxw | grep tclsh | grep pcap_agent | awk '{print $2}'`
>        if [ ${rc_pid} ]; then
>                kill -TERM ${rc_pid}
>        else
>                echo "${name} not running?"
>        fi
> }
>
> When I run onestatus, I get nothing from the status function:
>
> # /usr/local/etc/rc.d/pcap_agent onestatus
> /usr/local/etc/rc.d/pcap_agent: DEBUG: checkyesno: pcap_agent_enable is
set to YES.
> /usr/local/etc/rc.d/pcap_agent: DEBUG: run_rc_command: doit:
pcap_agent_status()
>
> Same thing for onestop:
> # /usr/local/etc/rc.d/pcap_agent onestop
> /usr/local/etc/rc.d/pcap_agent: DEBUG: checkyesno: pcap_agent_enable is
set to YES.
> /usr/local/etc/rc.d/pcap_agent: DEBUG: run_rc_command: doit:
pcap_agent_stop()
>
> As you can see, rc.subr is calling the function, but absolutely nothing
happens inside that function.  I've even tried adding an echo "Hello
world!" and that doesn't print.
>
> I'm sure there some simple syntax thing I'm missing here, but my eyeballs
are crossing from reading man (8) rc.subr and the "Practical rc.d scripting
in BSD" article by Yar Tikhiy.

Use a pidfile.  I would give an example, but I'm pushed for time, sorry.

If you get stuck I'll help as much as I can :)

Chris



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CADLo83-Zmt3_KSS3FPM5%2BYnZNrAFqkVV8sGNzKO0EyD8ChJP%2Bw>