[SLUG] homebrew init.d script management

From: Eben King (eben01@verizon.net)
Date: Sun Jun 22 2008 - 17:07:19 EDT


So I wrote this script a while back, and have been adding and deleting
things as needed:

22826 pts/3 S 0:00 /bin/ksh /export/bin/logmonitor
22829 pts/3 S 0:00 \_ tail --follow --lines=1 /var/log/messages /var/log/messages /var/log/syslog /var/log/auth.log /var/log/user.log
22830 pts/3 S 0:00 \_ /bin/ksh /export/bin/logmonitor

When I started writing it (which was probably not long after 1998) I was
using RH. Now, I'm using Ubuntu. /etc/init.d/logmonitor does this:

,--
| case "$1" in
| start)
| log_begin_msg "Starting logmonitor"
| start-stop-daemon --start --quiet --exec /export/bin/logmonitor
| log_begin_msg "Status: $?"
| ;;
| stop)
| log_begin_msg "Stopping logmonitor"
| start-stop-daemon --stop --quiet --oknodo --retry 2 --pidfile /var/run/logmonitor.pid
| log_begin_msg "Status: $?"
| ;;
...
'--

and /export/bin/logmonitor does this:

,--
| {
... # handlers go here
| tail --follow --lines=1 /var/log/{messages,syslog,{auth,user}.log} \
| | while read line ; do
...
| case $line in
... # various messages here, each associated with a handler
| esac
| done
| } &
|
| # to make sure the tail is up
| sleep 1
|
| ps --format 'pid command' \
| | sed -e '/tail/!d' -e 's/^ *//' -e "/^$/d" \
| | cut -f 1 -d ' ' > $pidfile
'--

It starts fine, but fails to stop properly. In the example above, it would
kill the tail (PID 22829) but leave the two logmonitors (PIDs 22826 and
22830). (26 is the parent, 30 is the child. When both children are killed,
the parent goes away.) logrotate (or something) runs every night, so
logmonitor doesn't work until I kill and restart it. What's the proper way
to fix it so it works?

-- 
-eben   QebWenE01R@vTerYizUonI.nOetP   royalty.mine.nu:81

My parents went to a planet where the inhabitants have no bilateral symmetry, and all I got was this lousy F-shirt. ----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:07:03 EDT