Package: postgrey Version: 1.32-3 Severity: normal Tags: patch Hi, concerning the HA Linux (http://linux-ha.org/, package heartbeat) one need at least a LSB script for controlling every HA service. Postfix package has sufficient init script, but Postgrey's init script has some deficiencies. * It has no status subcommand - HA needs it. * Init script is not idempotent on start (bad option for start-stop-daemon)
Example: sid:/etc/init.d# ./postgrey start; echo $? Starting postfix greylisting daemon: postgrey. 0 sid:/etc/init.d# ./postgrey start; echo $? Starting postfix greylisting daemon: postgreyPid_file already exists for running process (19566)... aborting ERROR: Pid_file already exists for running process (19566)... aborting 9 sid:/etc/init.d# ./postgrey start; echo $? Starting postfix greylisting daemon: postgreyPid_file already exists for running process (19566)... aborting ERROR: Pid_file already exists for running process (19566)... aborting 9 I prepared a changes of init script, that uses /lib/lsb/init-functions (lsb-base). It is used on Postfix initscript too. A function status_of_proc for status subcommand is used and this function was included into lsb-base in 3.2-14 (according to changelog.Debian), so dependecy on lsb-base (>= 3.2-14) should be added. The patched version of init script now behaves a bit better: sid:/etc/init.d# ./postgrey status; echo $? postgrey is not running failed! 3 sid:/etc/init.d# ./postgrey start; echo $? Starting postfix greylisting daemon: postgrey. 0 sid:/etc/init.d# ./postgrey status; echo $? postgrey is running. 0 sid:/etc/init.d# ./postgrey start; echo $? Starting postfix greylisting daemon: postgrey. 0 sid:/etc/init.d# ./postgrey stop; echo $? Stopping postfix greylisting daemon: postgrey. 0 sid:/etc/init.d# ./postgrey stop; echo $? Stopping postfix greylisting daemon: postgrey. 0 sid:/etc/init.d# ./postgrey reload; echo $? Reloading postfix greylisting daemon configuration......failed. 1 sid:/etc/init.d# ./postgrey start; echo $? Starting postfix greylisting daemon: postgrey. 0 sid:/etc/init.d# ./postgrey reload; echo $? Reloading postfix greylisting daemon configuration......done. 0 The above is in compliance with http://refspecs.linux-foundation.org/LSB_3.2.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html The patch and the whole rewritten script is included in this bugreport. I hope it could be acceptable. Best Regards -- Zito -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: i386 (i686) Kernel: Linux 2.6.26-1-686 (SMP w/1 CPU core) Locale: LANG=en_US.UTF-8, LC_CTYPE=cs_CZ.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages postgrey depends on: ii adduser 3.110 add and remove users and groups ii debconf 1.5.26 Debian configuration management sy ii libberkeleydb-perl 0.38-1 use Berkeley DB 4 databases from P ii libnet-dns-perl 0.65-1 Perform DNS queries from a Perl sc ii libnet-server-perl 0.97-1 An extensible, general perl server ii perl 5.10.0-19 Larry Wall's Practical Extraction ii ucf 3.0018 Update Configuration File: preserv Versions of packages postgrey recommends: ii libdigest-sha1-perl 2.11-2+b1 NIST SHA-1 message digest algorith ii libnet-rblclient-perl 0.5-2 Queries multiple Realtime Blackhol ii libparse-syslog-perl 1.10-1 Perl module for parsing syslog ent ii postfix 2.5.5-1.1 High-performance mail transport ag postgrey suggests no packages. -- debconf information excluded
#! /bin/sh # # postgrey start/stop the postgrey greylisting deamon for postfix # (priority should be smaller than that of postfix) # # Author: (c)2004-2006 Adrian von Bidder <avbid...@fortytwo.ch> # Based on Debian sarge's 'skeleton' example # Distribute and/or modify at will. # # Version: $Id: postgrey.init 1436 2006-12-07 07:15:03Z avbidder $ # ### BEGIN INIT INFO # Provides: postgrey # Required-Start: $syslog, $local_fs # Required-Stop: $syslog, $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/stop the postgrey daemon ### END INIT INFO set -e PATH=/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/postgrey NAME=postgrey DESC="postfix greylisting daemon" PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 . /lib/lsb/init-functions # Read config file if it is present. if [ -r /etc/default/$NAME ] then . /etc/default/$NAME fi POSTGREY_OPTS="--pidfile=$PIDFILE --daemonize $POSTGREY_OPTS" if [ -z "$POSTGREY_TEXT" ]; then POSTGREY_TEXT_OPT="" else POSTGREY_TEXT_OPT="--greylist-text=$POSTGREY_TEXT" fi ret=0 case "$1" in start) log_daemon_msg "Starting $DESC" "$NAME" if start-stop-daemon --start --oknodo --quiet \ --pidfile $PIDFILE --name $NAME \ --startas $DAEMON -- $POSTGREY_OPTS "$POSTGREY_TEXT_OPT" then log_end_msg 0 else ret=$? log_end_msg 1 fi ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" if start-stop-daemon --stop --oknodo --quiet \ --pidfile $PIDFILE --name $NAME then log_end_msg 0 else ret=$? log_end_msg 1 fi rm -f $PIDFILE ;; reload|force-reload) log_action_begin_msg "Reloading $DESC configuration..." if start-stop-daemon --stop --signal 1 --quiet \ --pidfile $PIDFILE --name $NAME then log_action_end_msg 0 else ret=$? log_action_end_msg 1 fi ;; restart) $0 stop $0 start ret=$? ;; status) status_of_proc -p $PIDFILE $DAEMON "$NAME" 2>/dev/null ret=$? ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2 exit 1 ;; esac exit $ret
diff --git a/init.d/postgrey b/init.d/postgrey index 76e5d0e..b0b2aa1 100755 --- a/init.d/postgrey +++ b/init.d/postgrey @@ -31,6 +31,8 @@ SCRIPTNAME=/etc/init.d/$NAME # Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 +. /lib/lsb/init-functions + # Read config file if it is present. if [ -r /etc/default/$NAME ] then @@ -44,37 +46,57 @@ else POSTGREY_TEXT_OPT="--greylist-text=$POSTGREY_TEXT" fi +ret=0 case "$1" in start) - echo -n "Starting $DESC: $NAME" - start-stop-daemon --start --quiet --pidfile $PIDFILE \ - --exec $DAEMON -- $POSTGREY_OPTS "$POSTGREY_TEXT_OPT" - echo "." + log_daemon_msg "Starting $DESC" "$NAME" + if start-stop-daemon --start --oknodo --quiet \ + --pidfile $PIDFILE --name $NAME \ + --startas $DAEMON -- $POSTGREY_OPTS "$POSTGREY_TEXT_OPT" + then + log_end_msg 0 + else + ret=$? + log_end_msg 1 + fi ;; stop) - echo -n "Stopping $DESC: $NAME" - start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo + log_daemon_msg "Stopping $DESC" "$NAME" + if start-stop-daemon --stop --oknodo --quiet \ + --pidfile $PIDFILE --name $NAME + then + log_end_msg 0 + else + ret=$? + log_end_msg 1 + fi rm -f $PIDFILE - echo "." ;; reload|force-reload) - echo -n "Reloading $DESC configuration..." - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE - echo "done." + log_action_begin_msg "Reloading $DESC configuration..." + if start-stop-daemon --stop --signal 1 --quiet \ + --pidfile $PIDFILE --name $NAME + then + log_action_end_msg 0 + else + ret=$? + log_action_end_msg 1 + fi ;; restart) - echo -n "Restarting $DESC: $NAME" - start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE - rm -f $PIDFILE - sleep 1 - start-stop-daemon --start --quiet --pidfile $PIDFILE \ - --exec $DAEMON -- $POSTGREY_OPTS "$POSTGREY_TEXT_OPT" - echo "." + $0 stop + $0 start + ret=$? ;; + status) + status_of_proc -p $PIDFILE $DAEMON "$NAME" 2>/dev/null + ret=$? + ;; + *) - echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2 exit 1 ;; esac -exit 0 +exit $ret