/rc0.d/K20courier-pop

http://github.com/brinkman83/bashrc · Shell · 105 lines · 78 code · 15 blank · 12 comment · 11 complexity · 01563971b66842f9b93e18aa95ab6fea MD5 · raw file

  1. #! /bin/sh -e
  2. ### BEGIN INIT INFO
  3. # Short-Description: Courier POP3 server
  4. # Provides: courier-pop
  5. # Required-Start: $remote_fs $syslog
  6. # Required-Stop: $remote_fs $syslog
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Description: courier-pop is an POP3 Mail Delivery Agent.
  10. ### END INIT INFO
  11. prefix="/usr"
  12. exec_prefix=${prefix}
  13. sysconfdir="/etc/courier"
  14. sbindir="${exec_prefix}/sbin"
  15. libexecdir="${prefix}/lib/courier"
  16. run_dir="/var/run/courier"
  17. calendar_dir="/var/run/courier/calendar"
  18. TCPD="${sbindir}/couriertcpd"
  19. DAEMON=${sbindir}/pop3d
  20. PROGRAM="Courier POP3 server"
  21. PROG="pop3d"
  22. SSLCONFIG=
  23. test -f $DAEMON || exit 0
  24. . /lib/lsb/init-functions
  25. if [ ! -d ${run_dir} ]; then
  26. mkdir -p ${run_dir}
  27. chown daemon:daemon ${run_dir}
  28. fi
  29. if [ ! -d ${calendar_dir} ]; then
  30. mkdir -p ${calendar_dir}
  31. chown daemon:daemon ${calendar_dir}
  32. fi
  33. if ! [ -x $TCPD ]; then
  34. log_failure_msg "ERR: $TCPD missing"
  35. exit 1
  36. fi
  37. if ! [ -f ${sysconfdir}/pop3d ]; then
  38. log_failure_msg "ERR: config file missing"
  39. exit 1
  40. fi
  41. # read/set defaults
  42. if [ -f /etc/default/courier ]; then
  43. . /etc/default/courier
  44. fi
  45. # ensure that maildirpath is set
  46. if [ -z "$MAILDIRPATH" ]; then
  47. MAILDIRPATH=Maildir
  48. fi
  49. if [ -f "${sysconfdir}/pop3d-ssl" ]; then
  50. . "${sysconfdir}/pop3d-ssl"
  51. SSLCONFIG=1
  52. fi
  53. . ${sysconfdir}/pop3d
  54. START=no
  55. case "$POP3DSTART" in
  56. [yY]*)START=yes;;
  57. esac
  58. case "$1" in
  59. start)
  60. if [ "$START" = "yes" ]; then
  61. log_begin_msg "Starting $PROGRAM..."
  62. /usr/bin/env - /bin/sh -c " set -a; \
  63. . ${sysconfdir}/pop3d; \
  64. if [ "$SSLCONFIG" ]; then . ${sysconfdir}/pop3d-ssl; fi; \
  65. POP3_STARTTLS=$POP3_STARTTLS; export POP3_STARTTLS; \
  66. TLS_PROTOCOL=$TLS_STARTTLS_PROTOCOL; \
  67. /usr/sbin/courierlogger -pid=$PIDFILE -start $LOGGEROPTS \
  68. $TCPD \
  69. -maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
  70. $TCPDOPTS -address=$ADDRESS $PORT \
  71. ${libexecdir}/courier/courierpop3login $AUTHMODULELIST \
  72. ${libexecdir}/courier/courierpop3d $MAILDIRPATH"
  73. log_end_msg 0
  74. fi
  75. ;;
  76. stop)
  77. log_begin_msg "Stopping $PROGRAM..."
  78. $TCPD -pid=$PIDFILE -stop || log_end_msg 1
  79. log_end_msg 0
  80. ;;
  81. restart | force-reload)
  82. $0 stop
  83. $0 start
  84. ;;
  85. *)
  86. log_success_msg "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
  87. exit 1
  88. ;;
  89. esac
  90. exit 0