You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

postsrsd.rh_init.in 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #! /bin/sh
  2. #
  3. # @PROJECT_NAME@
  4. # start/stop the @PROJECT_NAME@ daemon for Postfix
  5. #
  6. # chkconfig: 2345 75 35
  7. # description: Sender Rewriting Scheme (SRS) for Postfix.
  8. # processname: @POSTSRSD@
  9. # pidfile: /var/run/@PROJECT_NAME@.pid
  10. # config: @CONFIG_DIR@/@PROJECT_NAME@
  11. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  12. DAEMON=@CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@
  13. NAME=@PROJECT_NAME@
  14. prog=@POSTSRSD@
  15. DESC="Postfix Sender Rewriting Scheme daemon"
  16. PIDFILE=/var/run/$NAME.pid
  17. SCRIPTNAME=/etc/init.d/$NAME
  18. # Gracefully exit if the package has been removed.
  19. test -x $DAEMON || exit 0
  20. . /etc/init.d/functions
  21. # Default configuration
  22. SRS_DOMAIN=`postconf -h mydomain || true`
  23. SRS_FORWARD_PORT=10001
  24. SRS_REVERSE_PORT=10002
  25. SRS_SECRET=/etc/@PROJECT_NAME@.secret
  26. RUN_AS=nobody
  27. CHROOT=@CHROOT_DIR@
  28. # Read config file if it is present.
  29. if [ -r @CONFIG_DIR@/$NAME ]
  30. then
  31. . @CONFIG_DIR@/$NAME
  32. fi
  33. test -r "$SRS_SECRET" -a -n "$SRS_DOMAIN" || exit 0
  34. do_start()
  35. {
  36. echo -n "Starting $DESC: "
  37. daemon $DAEMON -4 -f"$SRS_FORWARD_PORT" -r"$SRS_REVERSE_PORT" -d"$SRS_DOMAIN" -s"$SRS_SECRET" \
  38. -u"$RUN_AS" -p"$PIDFILE" -c"$CHROOT" -X"$SRS_EXCLUDE_DOMAINS" -D
  39. RETVAL=$?
  40. echo
  41. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$NAME
  42. return $RETVAL
  43. }
  44. do_stop()
  45. {
  46. echo -n "Stopping $DESC: "
  47. killproc $prog
  48. RETVAL=$?
  49. echo
  50. [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$NAME
  51. return $RETVAL
  52. }
  53. case "$1" in
  54. start)
  55. do_start
  56. ;;
  57. stop)
  58. do_stop
  59. ;;
  60. status)
  61. status $NAME
  62. ;;
  63. restart|force-reload)
  64. do_stop
  65. do_start
  66. ;;
  67. reload)
  68. ;;
  69. condrestart|try-restart)
  70. if [ -f /var/lock/subsys/$NAME ]; then
  71. do_stop
  72. do_start
  73. fi
  74. ;;
  75. *)
  76. echo "Usage: $NAME {start|stop|restart|condrestart|try-restart|reload|force-reload|status|usage}"
  77. [ "$1" = "usage" ] && exit 0
  78. exit 2
  79. ;;
  80. esac
  81. exit $?