On Mon, Jun 30, 2008 at 09:34:17AM +0200, Tim Stoop wrote: > Op 28-jun-2008, om 15:25 heeft Christian Perrier het volgende > geschreven: >> I think you're very welcome to propose a patch. We'll review it >> (indeed, Steve will criticize it and I'll just look..:-)) and, >> hopefully, integrate it.
Here comes the criticism ;) > This is my addition to the initscript for samba: > status) > SMBRETURN=3 > NMBRETURN=3 > PIDS_SMBD=`pidof smbd > /dev/null; echo $?` > PIDS_NMBD=`pidof nmbd > /dev/null; echo $?` This is wrong. 'pidof' will check for any running process under this name; we should be looking for only those processes that are started by this init script itself, excluding any processes that might randomly have the same name or that are started by a user outside of this init script (e.g., a custom set up of samba running on a different port... you'll find that qemu does this for filesharing, though currently not very successfully on Debian...) So the right way to do this is to look at the PID files themselves first, check their contents, and verify that those processes are still running. Something like: if [ ! -f $SMBDPID ]; then echo "smbd not running." else PIDS_SMBD=`cat $SMBDPID` if ps $PIDS_SMBD | grep -q smbd; then echo "smbd running." SMBRETURN=0 else echo "smbd running, but pidfile exists." SMBRETURN=1 fi fi Note that procps is required for this functionality to work, because of the use of ps. I don't know that a dependency is actually warranted, since this is optional functionality; anyway, procps is Priority: required, so it will always be present in practice. I don't have a problem with the 'echo' statements myself, though I do object to the use of exclamation marks. :) > if [ $SMBRETURN -eq 1 ] || [ $SMBRETURN -eq 1 ] > then > exit 1 > elif [ $SMBRETURN -eq $NMBRETURN ] > then > exit $SMBRETURN > else > # Apparantly, we have an unknown state, or at least something > # that we can't fix easily > return 4 > fi > ;; Well, this means that no meaningful status will be returned if one of the daemons is running but the other is not. Concretely, this means it won't return useful status in the event that smbd is started out of inetd (RUN_MODE=inetd), or that 'disable netbios' is set, causing nmbd to not be run. > The same for winbind (much simpler): > > status) > PIDS_WINBIND=`pidof winbindd > /dev/null; echo $?` > if [ $PIDS_WINBIND -eq 0 ] > then > echo "winbind is running" > exit 0 > else > echo "winbind is stopped" > exit 3 > fi > ;; I think it would be better to first fix winbind to use a proper PID file, then use code similar to that in the smbd/nmbd case. Cheers, -- Steve Langasek Give me a lever long enough and a Free OS Debian Developer to set it on, and I can move the world. Ubuntu Developer http://www.debian.org/ [EMAIL PROTECTED] [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]