[Pkg-samba-maint] Yet another Ubuntu patch: adding a status section to init script

Julien Cristau jcristau at debian.org
Sun Mar 30 11:01:43 UTC 2008


On Sun, Mar 30, 2008 at 12:40:46 +0200, Christian Perrier wrote:

> Quoting Steve Langasek (vorlon at debian.org):
> 
> > > +		pidofproc -p $SMBDPID $DAEMON >/dev/null
> > > +		status=$?
> > > +		if [ $status -eq 0 ]; then
> > > +			log_success_msg "SMBD is running"
> > > +		else
> > > +			log_failure_msg "SMBD is not running"
> > > +		fi
> > > +		exit $status
> > 
> > Hnngh, not clean under set -e.  Ever since the LSB init script lib was
> > introduced to Debian, error handling in init scripts has gone downhill...
> 
> 
> Hmmm, I fail to understand what's needed here. Sorry for being
> dumb..:)
> 
Under set -e, if pidofproc returns non-zero, the whole script will fail.
You want something like this:
if pidofproc -p $SMBDPID $DAEMON >/dev/null; then
        log_success_msg "SMBD is running"
        exit 0
else
        status=$?
        log_failure_msg "SMBD is not running"
        exit $status
fi

Cheers,
Julien



More information about the Pkg-samba-maint mailing list