選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

postsrsd.lsb_init.in 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 $network $local_fs
  9. # Required-Stop: $syslog $network $local_fs
  10. # Default-Start: 2 3 4 5
  11. # Default-Stop: 0 1 6
  12. # Short-Description: Start/stop the @PROJECT_NAME@ 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=@SYSCONF_DIR@/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=@SYSCONF_DIR@/@PROJECT_NAME@.secret
  29. RUN_AS=nobody
  30. CHROOT=@CHROOT_DIR@
  31. # Read config file if it is present.
  32. if [ -r @CONFIG_DIR@/$NAME ]
  33. then
  34. . @CONFIG_DIR@/$NAME
  35. fi
  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 \
  45. -- -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
  46. then
  47. log_end_msg 0
  48. else
  49. ret=$?
  50. log_end_msg 1
  51. fi
  52. ;;
  53. stop)
  54. log_daemon_msg "Stopping $DESC" "$NAME"
  55. if start-stop-daemon --stop --oknodo --quiet \
  56. --pidfile $PIDFILE --name $NAME
  57. then
  58. log_end_msg 0
  59. else
  60. ret=$?
  61. log_end_msg 1
  62. fi
  63. rm -f $PIDFILE
  64. ;;
  65. reload|force-reload|restart)
  66. $0 stop
  67. $0 start
  68. ret=$?
  69. ;;
  70. status)
  71. log_daemon_msg "postsrsd is running"
  72. if [ -s $PIDFILE ]; then
  73. PID=`cat $PIDFILE`
  74. if kill -0 "$PID" 2>/dev/null; then
  75. log_end_msg 0
  76. else
  77. log_end_msg 1
  78. fi
  79. else
  80. log_end_msg 1
  81. fi
  82. ;;
  83. *)
  84. echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2
  85. exit 1
  86. ;;
  87. esac
  88. exit $ret