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.

--
Paul Schmehl, Senior Infosec Analyst
As if it wasn't already obvious, my opinions
are my own and not those of my employer.
*******************************************
"It is as useless to argue with those who have
renounced the use of reason as to administer
medication to the dead." Thomas Jefferson
"There are some ideas so wrong that only a very
intelligent person could believe in them." George Orwell

_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-rc
To unsubscribe, send any mail to "[email protected]"

Reply via email to