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.init.in 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #! /bin/sh
  2. #
  3. # @PROJECT_NAME@
  4. # start/stop the @PROJECT_NAME@ daemon for Postfix
  5. #
  6. ### BEGIN INIT INFO
  7. # Provides: @PROJECT_NAME@
  8. # Required-Start: $syslog, $local_fs
  9. # Required-Stop: $syslog, $local_fs
  10. # Default-Start: 2 3 4 5
  11. # Default-Stop: 0 1 6
  12. # Short-Description: Start/stop the postsrs daemon
  13. ### END INIT INFO
  14. set -e
  15. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  16. DAEMON=@CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@
  17. NAME=@PROJECT_NAME@
  18. DESC="Postfix Sender Rewriting Scheme daemon"
  19. PIDFILE=/var/run/$NAME.pid
  20. SCRIPTNAME=/etc/init.d/$NAME
  21. # Gracefully exit if the package has been removed.
  22. test -x $DAEMON || exit 0
  23. . /lib/lsb/init-functions
  24. # Default configuration
  25. SRS_DOMAIN=`postconf -h mydomain || true`
  26. SRS_FORWARD_PORT=10001
  27. SRS_REVERSE_PORT=10002
  28. SRS_SECRET=/etc/@PROJECT_NAME@.secret
  29. RUN_AS=nobody
  30. # Read config file if it is present.
  31. if [ -r /etc/default/$NAME ]
  32. then
  33. . /etc/default/$NAME
  34. fi
  35. POSTSRS_OPTS="-4 -f$SRS_FORWARD_PORT -r$SRS_REVERSE_PORT -d$SRS_DOMAIN -s$SRS_SECRET -u$RUN_AS -p$PIDFILE -D"
  36. test -r "$SRS_SECRET" -a -n "$SRS_DOMAIN" || exit 0
  37. ret=0
  38. case "$1" in
  39. start)
  40. log_daemon_msg "Starting $DESC" "$NAME"
  41. if start-stop-daemon --start --oknodo --quiet \
  42. --pidfile $PIDFILE \
  43. --name $NAME \
  44. --startas $DAEMON -- $POSTSRS_OPTS
  45. then
  46. log_end_msg 0
  47. else
  48. ret=$?
  49. log_end_msg 1
  50. fi
  51. ;;
  52. stop)
  53. log_daemon_msg "Stopping $DESC" "$NAME"
  54. if start-stop-daemon --stop --oknodo --quiet \
  55. --pidfile $PIDFILE --name $NAME
  56. then
  57. log_end_msg 0
  58. else
  59. ret=$?
  60. log_end_msg 1
  61. fi
  62. rm -f $PIDFILE
  63. ;;
  64. reload|force-reload|restart)
  65. $0 stop
  66. $0 start
  67. ret=$?
  68. ;;
  69. *)
  70. echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  71. exit 1
  72. ;;
  73. esac
  74. exit $ret