On Tue, Jul 22, 2003 at 01:21:21AM -0700, Andi Payn wrote: > I agree; this would be a useful thing to add to the standard dnotify package. > But I'd suggest two minor changes. > > It might be better to have an /etc/sysconfig/dnotify.d directory instead of a > single file. This is easy, and potentially useful (e.g., for future packages > to drop their own dnotify commands in place).
Done and attached. The README file that is attached should go in /etc/sysconfig/dnotify.d for documentation purposes... > Also, I think better examples would be very helpful. Yeah, it's not too hard > to figure things out from the manpage, but on the other hand, the examples > that are provided. are more apt to be confusing than helpful to a newbie. > > Running dnotify -A /etc -e echo change will print "change" whenever a file in > /etc is read--but not when a file in /etc is changed. And the other example > will call "informdelete" whenever a file in /var/mail is deleted, but also > whenever one created. So, it'll be triggered whenever a mailbox is created or > destroyed, which is unlikely to be a good reason to call something called > informdelete. So, both of the examples are more likely to confuse than > enlighten newbies. > > Also, the first example will print "change" to stdout, which is not likely to > be what you want in a program backgrounded by an init script. And the second > will likewise print its output to stdout--and, if informdelete returns > nonzero, dnotify will print a warning to stderr. So, examples showing > redirection would also be nice. > > And, since dnotify will run everything as root, examples showing dropping root > might be handy. > > Finally, it would be nice to have examples of something someone might want to > actually do. > > Something like this: > -CDMRB -r /etc/httpd -e service httpd configtest >> /var/log/dnotify > -CDMR -p1q0 /var/mirror/urpm -e su -c'/usr/local/bin/rebuildhdlist >> > /var/log/urpmirror' urpmirror > etc. Thanks, I just copied the examples out of the man page. :) Also attached is an updated copy with the examples fixed. > It might even be better to have cron-ish TSV/CSV/whatever config files, so it > could just be something like: > #cond dir recurse procs queues user stdout[:stderr[:dnotifyerr]] cmd > CDMRB /etc/httpd r - - - - service httpd configtest > CDMR /var/mirror/urpm - 1 0 urpmirror /var/log/urpmirror:- > /usr/local/bin/rebuildhdlist > > But that's probably overkill. Just a /etc/sysconfig/dnotify.d and a set of > useful examples, and I'd be more than happy. Yeah I think that's overkill. -- Ben Reser <[EMAIL PROTECTED]> http://ben.reser.org "What upsets me is not that you lied to me, but that from now on I can no longer believe you." -- Nietzsche
# Each file in this directory is interpreted the same way the # /etc/sysconfig/dnotify file is. See its contents for details # and examples.
#!/bin/sh # # Startup script for dnotify # # chkconfig: 345 91 15 # description: dnotify executes a command when the contents of a \ # directory change # processname: dnotify # config: /etc/sysconfig/dnotify # # By: Ben Reser <[EMAIL PROTECTED]> # Source function library. . /etc/rc.d/init.d/functions [ -x /usr/bin/dnotify ] || exit 0 [ -r /etc/sysconfig/dnotify ] && [ -f /etc/sysconfig/dnotify ] || exit 0 [ -r /etc/sysconfig/dnotify.d ] && [ -d /etc/sysconfig/dnotify.d ] || exit 0 RETVAL=0 # See how we were called. case "$1" in start) gprintf "Starting dnotify: " egrep -shv '^([[:space:]]*#|[[:space:]]*$)' /etc/sysconfig/dnotify \ /etc/sysconfig/dnotify.d/* | while read args; do /usr/bin/dnotify $args & # Make sure any failure is saved in RETVAL retval_temp=$? [ $retval_temp -ne 0 ] && RETVAL=$retval_temp done; [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dnotify && success || failure echo ;; stop) gprintf "Shutting down dnotify: " killall /usr/bin/dnotify 1>&2 2> /dev/null RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dnotify && success || failure echo ;; status) status dnotify RETVAL=$? ;; restart) $0 stop $0 start RETVAL=$? ;; *) gprintf "Usage: %s {start|stop|status|restart" "$0" exit 1 esac exit $RETVAL
# This file allows you to specify instances of dnotify # that should be started by the dnotify init script. # Each line that does not start with a # character # represents an instance of dnotify command to start. # The line will contain the command line args to pass dnotify. # E.G. (of course without the #): # -CDMRB -r /etc/httpd -e service httpd configtest >> /var/log/dnotify # -CDMR -p1q0 /var/mirror/urpm -e su -c'/usr/local/bin/rebuildhdlist >> /var/log/urpmirror' urpmirror