Hi Augustin On Sun, Jan 23, 2011 at 01:38:47AM +0100, Agustin Martin wrote: > 2011/1/21 Teodor MICU <mteo...@gmail.com>: > > 2011/1/21 Agustin Martin <agmar...@debian.org>: > >> if [ "$MILTERSOCKET" ] && [ "`echo $MILTERSOCKET | grep -v ^inet`" ]; then > >> > >> but as Teodor points out (just read it), second check seems to be enough. > > > > Only that I realized latter the intention of this construction. My > > previous suggestion was to use this construction on its own without > > "test": > > > > if echo "$MILTERSOCKET" | grep -q -v "^inet"; then > > ... > > fi > > (the return code is set by grep) > > > > This works too but there is an extra test for the empty string: > > if [ "$(echo $MILTERSOCKET | grep -v ^inet)" ]; then > > ... > > fi > > (the return code is set by 'test') > > If I understand correctly, first expression saves redundant checks, so > is preferrable.
I will have a to check this - this is meant as a guard against accidently setting $MILTERSOCKET to "". > > Harald, I've rewritten patch suggestion with more quoting and Teodor's > check (Teodor, please check that I understood correctly) . Thanks > Instead of > repeating the check a variable is used for next similar check, but > that was the way I played, feel free to act at your convenience. Will take a look at this today (as work permits). > I do > not use amavisd myself, so patch is completely unchecked, just > verified that 'sh -n' on the script gives no errors. Check on this is > appreciated. Ok thank you very much. > > Patch is attached, Thanks again. > > Cheers, > > -- > Agustin Kind regards Harald > diff -Nru --exclude changelog amavisd-milter-1.5.0/debian/amavisd-milter.init > amavisd-milter-1.5.0/debian/amavisd-milter.init > --- amavisd-milter-1.5.0/debian/amavisd-milter.init 2010-05-12 > 23:01:42.000000000 +0200 > +++ amavisd-milter-1.5.0/debian/amavisd-milter.init 2011-01-22 > 20:40:46.000000000 +0100 > @@ -30,19 +30,43 @@ > OPTIONS="" > > # Exit if the package is not installed > -[ -x $DAEMON ] || exit 0 > +[ -x "$DAEMON" ] || exit 0 > > # Read configuration variable file if it is present > -[ -r /etc/default/$NAME ] && . /etc/default/$NAME > - > -[ $PIDFILE != "/var/run/amavis/$NAME.pid" ] && OPTIONS="$OPTIONS -p $PIDFILE" > -[ $MILTERSOCKET ] && OPTIONS="$OPTIONS -s $MILTERSOCKET" > -[ $AMAVISSOCKET ] && OPTIONS="$OPTIONS -S $AMAVISSOCKET" > -[ $WORKINGDIR ] && OPTIONS="$OPTIONS -w $WORKINGDIR" > -[ $EXTRAPARAMS ] && OPTIONS="$OPTIONS $EXTRAPARAMS" > - > -[ $PIDFILE ] && ([ -d $(dirname $PIDFILE) ] || mkdir $(dirname $PIDFILE) && > chown $USER:$(id $USER -g -n) $(dirname $PIDFILE)) > -[ $MILTERSOCKET ] && ([ -d $(dirname $MILTERSOCKET) ] || mkdir $(dirname > $MILTERSOCKET) && chown $USER $(dirname $MILTERSOCKET)) > +if [ -r "/etc/default/$NAME" ]; then > + . "/etc/default/$NAME" > +fi > + > +if [ "$PIDFILE" != "/var/run/amavis/$NAME.pid" ]; then > + OPTIONS="$OPTIONS -p $PIDFILE" > +fi > +if [ "$MILTERSOCKET" ]; then > + OPTIONS="$OPTIONS -s $MILTERSOCKET" > +fi > +if [ "$AMAVISSOCKET" ]; then > + OPTIONS="$OPTIONS -S $AMAVISSOCKET" > +fi > +if [ "$WORKINGDIR" ]; then > + OPTIONS="$OPTIONS -w $WORKINGDIR" > +fi > +if [ "$EXTRAPARAMS" ]; then > + OPTIONS="$OPTIONS $EXTRAPARAMS" > +fi > + > +if [ "$PIDFILE" ]; then > + if [ ! -e "$(dirname $PIDFILE)" ]; then > + mkdir "$(dirname $PIDFILE)" > + fi > + chown $USER:$(id $USER -g -n) "$(dirname $PIDFILE)" > +fi > +unset NOINET_MILTERSOCKET > +if echo "$MILTERSOCKET" | grep -q -v "^inet"; then > + if [ ! -e "$(dirname $MILTERSOCKET)" ]; then > + mkdir "$(dirname $MILTERSOCKET)" > + fi > + NOINET_MILTERSOCKET=1 > + chown $USER "$(dirname $MILTERSOCKET)" > +fi > > START="--start --quiet --chuid $USER --pidfile $PIDFILE --startas $DAEMON > --name $NAME -- $OPTIONS" > STOP="--stop --quiet --retry 10 --pidfile $PIDFILE --startas $DAEMON --name > $NAME" > @@ -53,25 +77,51 @@ > case "$1" in > start) > log_daemon_msg "Starting $DESC:" "$NAME" > - start-stop-daemon $START > + start-stop-daemon $START > + > case "$?" in > - 0) log_end_msg 0 > - [ $MILTERSOCKET ] && [ $MILTERSOCKETOWNER ] && chown > $MILTERSOCKETOWNER $MILTERSOCKET > - [ $MILTERSOCKET ] && [ $MILTERSOCKETMODE ] && chmod > $MILTERSOCKETMODE $MILTERSOCKET ;; > - 1) log_progress_msg "already started" > - log_end_msg 0 ;; > - *) log_end_msg $? ;; > + 0) > + log_end_msg 0 > + if [ "$NOINET_MILTERSOCKET" ]; then > + if [ "$MILTERSOCKETOWNER" ]; then > + chown $MILTERSOCKETOWNER $MILTERSOCKET > + fi > + if [ "$MILTERSOCKETMODE" ]; then > + chmod $MILTERSOCKETMODE $MILTERSOCKET > + fi > + fi > + ;; > + > + 1) > + log_progress_msg "already started" > + log_end_msg 0 > + ;; > + > + *) > + log_end_msg $? > + ;; > + > esac > ;; > > stop) > log_daemon_msg "Stopping $DESC:" "$NAME" > start-stop-daemon $STOP > + > case "$?" in > - 0) log_end_msg 0 ;; > - 1) log_progress_msg "already stopped" > - log_end_msg 0 ;; > - *) log_end_msg $? ;; > + 0) > + log_end_msg 0 > + ;; > + > + 1) > + log_progress_msg "already stopped" > + log_end_msg 0 > + ;; > + > + *) > + log_end_msg $? > + ;; > + > esac > ;; > -- To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org