1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #! /bin/sh
- #
- # @PROJECT_NAME@
- # start/stop the @PROJECT_NAME@ daemon for Postfix
- #
- # chkconfig: 2345 75 35
- # description: Sender Rewriting Scheme (SRS) for Postfix.
- # processname: @POSTSRSD@
- # pidfile: /var/run/@PROJECT_NAME@.pid
- # config: @CONFIG_DIR@/@PROJECT_NAME@
-
- PATH=/sbin:/bin:/usr/sbin:/usr/bin
- DAEMON=@CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@
- NAME=@PROJECT_NAME@
- prog=@POSTSRSD@
- DESC="Postfix Sender Rewriting Scheme daemon"
-
- PIDFILE=/var/run/$NAME.pid
- SCRIPTNAME=@SYSCONF_DIR@/init.d/$NAME
-
- # Gracefully exit if the package has been removed.
- test -x $DAEMON || exit 0
-
- . @SYSCONF_DIR@/init.d/functions
-
- # Default configuration
- SRS_DOMAIN=`postconf -h mydomain || true`
- SRS_FORWARD_PORT=10001
- SRS_REVERSE_PORT=10002
- SRS_SECRET=@SYSCONF_DIR@/@PROJECT_NAME@.secret
- RUN_AS=nobody
- CHROOT=@CHROOT_DIR@
-
- # Read config file if it is present.
- if [ -r @CONFIG_DIR@/$NAME ]
- then
- . @CONFIG_DIR@/$NAME
- fi
-
- test -r "$SRS_SECRET" -a -n "$SRS_DOMAIN" || exit 0
-
- do_start()
- {
- echo -n "Starting $DESC: "
- daemon $DAEMON -4 -f"$SRS_FORWARD_PORT" -r"$SRS_REVERSE_PORT" -d"$SRS_DOMAIN" -s"$SRS_SECRET" \
- -u"$RUN_AS" -p"$PIDFILE" -c"$CHROOT" -X"$SRS_EXCLUDE_DOMAINS" -D
- 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 $?
|