Need a clue about overriding default methods

Chris Rees utisoft at gmail.com
Wed Dec 19 20:28:28 UTC 2012


On 19 Dec 2012 17:19, "Paul Schmehl" <pschmehl_lists at 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


More information about the freebsd-rc mailing list