#! /bin/sh # # postsrsd # start/stop the postsrsd daemon for Postfix # # chkconfig: 2345 75 35 # description: Sender Rewriting Scheme (SRS) for Postfix. # processname: postsrsd # pidfile: /var/run/postsrsd.pid # config: /etc/default/postsrsd PATH=/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/postsrsd NAME=postsrsd prog=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 . /etc/init.d/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 do_start() { echo -n "Starting $DESC: " daemon $DAEMON $SRS_EXTRA_OPTIONS -f "$SRS_FORWARD_PORT" -r "$SRS_REVERSE_PORT" -d "$SRS_DOMAIN" \ -s "$SRS_SECRET" -n "$SRS_HASHLENGTH" -N "$SRS_HASHMIN" \ -u "$RUN_AS" -p "$PIDFILE" -a "$SRS_SEPARATOR" -c "$CHROOT" -l "$SRS_LISTEN_ADDR" -D -X"$SRS_EXCLUDE_DOMAINS" RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$NAME return $RETVAL } do_stop() { echo -n "Stopping $DESC: " killproc $prog RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$NAME return $RETVAL } case "$1" in start) do_start ;; stop) do_stop ;; status) status $NAME ;; restart|force-reload) do_stop do_start ;; reload) ;; condrestart|try-restart) if [ -f /var/lock/subsys/$NAME ]; then do_stop do_start fi ;; *) echo "Usage: $NAME {start|stop|restart|condrestart|try-restart|reload|force-reload|status|usage}" [ "$1" = "usage" ] && exit 0 exit 2 ;; esac exit $?