#! /bin/sh # # postsrsd # start/stop the postsrsd daemon for Postfix # ### BEGIN INIT INFO # Provides: postsrsd # Required-Start: $syslog $network $remote_fs # Required-Stop: $syslog $network $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/stop the postsrsd daemon # Description: postsrsd offers Sender Rewriting Scheme support for Postfix ### END INIT INFO set -e PATH=/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/postsrsd NAME=postsrsd DESC="Postfix Sender Rewriting Scheme 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 # Default configuration SRS_FORWARD_PORT=10001 SRS_REVERSE_PORT=10002 SRS_DOMAIN=`postconf -h mydomain || true` SRS_SECRET=/etc/postsrsd.secret SRS_SEPARATOR== SRS_HASHLENGTH=4 SRS_HASHMIN=4 SRS_EXTRA_OPTIONS= RUN_AS=nobody CHROOT=/usr/lib/postsrsd SRS_LISTEN_ADDR=127.0.0.1 SRS_EXCLUDE_DOMAINS= # Read config file if it is present if [ -r /etc/default/$NAME ] then . /etc/default/$NAME fi test -r "$SRS_SECRET" -a -n "$SRS_DOMAIN" || exit 1 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 \ -- $SRS_EXTRA_OPTIONS -f "$SRS_FORWARD_PORT" -r "$SRS_REVERSE_PORT" \ -d "$SRS_DOMAIN" -s "$SRS_SECRET" -a "$SRS_SEPARATOR" \ -n "$SRS_HASHLENGTH" -N "$SRS_HASHMIN" -u "$RUN_AS" -p "$PIDFILE" \ -c "$CHROOT" -l "$SRS_LISTEN_ADDR" -D -X"$SRS_EXCLUDE_DOMAINS" 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 --exec $DAEMON --name $NAME then log_end_msg 0 else ret=$? log_end_msg 1 fi rm -f $PIDFILE ;; reload|force-reload|restart) $0 stop $0 start ret=$? ;; status) log_daemon_msg "postsrsd is running" if [ -s $PIDFILE ]; then PID=`cat $PIDFILE` if kill -0 "$PID" 2>/dev/null; then log_end_msg 0 else log_end_msg 1 fi else log_end_msg 1 fi ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2 exit 1 ;; esac exit $ret