qpsmtpd.initd 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/sbin/openrc-run
  2. pidfile=/var/run/qpsmtpd/qpsmtpd.pid
  3. depend() {
  4. use logger dns ypbind amavisd mysql postgresql antivirus postfix_greylist net saslauthd
  5. provide mta
  6. }
  7. checkconfig() {
  8. if ! [ -d "${QPSMTPD_CONFIG:-/etc/qpsmtpd}" ]; then
  9. eerror "Configuration directory ${QPSMTPD_CONFIG:-/etc/qpsmtpd} does not exist."
  10. return 1
  11. fi
  12. return 0
  13. }
  14. start() {
  15. checkconfig || return 1
  16. ebegin "Starting qpsmtpd [${QPSMTPD_SERVER_TYPE}] server"
  17. HOME="/var/spool/qpsmtpd"
  18. local QPSMTPD_SERVER_BIN=""
  19. local myopts=""
  20. export QPSMTPD_CONFIG=${QPSMTPD_CONFIG}
  21. for foo in PERL_UNICODE LANG LC_TIME LC_ALL BASH_ENV ENV CDPATH IFS
  22. do
  23. unset ${foo}
  24. done
  25. case "${QPSMTPD_SERVER_TYPE}" in
  26. prefork)
  27. QPSMTPD_SERVER_BIN="/usr/bin/qpsmtpd-prefork"
  28. QPSMTPD_OPTIONS="$(echo "${QPSMTPD_OPTIONS}" | sed "s:\-\-pid\-file[\t ]\{1,99\}[^ ]*::gI")"
  29. # Option --pid-file is mentioned in the help of the prefork server
  30. # but does not work when specified.
  31. # QPSMTPD_OPTIONS="${QPSMTPD_OPTIONS} --pid-file ${pidfile}"
  32. myopts="${myopts} --make-pidfile --pidfile ${pidfile}"
  33. ;;
  34. async)
  35. QPSMTPD_SERVER_BIN="/usr/sbin/qpsmtpd-async"
  36. myopts="${myopts} --background --make-pidfile --pidfile ${pidfile}"
  37. ;;
  38. forkserver|*)
  39. QPSMTPD_SERVER_BIN="/usr/bin/qpsmtpd-forkserver"
  40. QPSMTPD_OPTIONS="$(echo "${QPSMTPD_OPTIONS}" | sed "s:\-\-pid\-file[\t ]\{1,99\}[^ ]*::gI")"
  41. QPSMTPD_OPTIONS="$(echo "${QPSMTPD_OPTIONS}" | sed "s:[\t ]\{0,99\}\-d[\t ]\{1,99\}|[\t ]\{1,99\}\-d[\t ]\{0,99\}::gI")"
  42. QPSMTPD_OPTIONS="$(echo "${QPSMTPD_OPTIONS}" | sed "s:[\t ]\{0,99\}\-\detach[\t ]\{1,99\}|[\t ]\{1,99\}\-\-detach[\t ]\{0,99\}::gI")"
  43. QPSMTPD_OPTIONS="${QPSMTPD_OPTIONS} --pid-file ${pidfile} --detach"
  44. myopts="${myopts} --pidfile ${pidfile}"
  45. ;;
  46. esac
  47. start-stop-daemon --start --nicelevel ${QPSMTPD_NICELEVEL:-0} \
  48. --quiet ${myopts} \
  49. --exec ${QPSMTPD_SERVER_BIN} \
  50. -- ${QPSMTPD_OPTIONS}
  51. eend $?
  52. }
  53. stop() {
  54. ebegin "Stopping qpsmtpd [${QPSMTPD_SERVER_TYPE}] server"
  55. start-stop-daemon --stop --quiet --pidfile ${pidfile}
  56. eend $?
  57. }