diff --git a/Dockerfile b/Dockerfile index 0dd6dff1..c33877aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,6 +47,7 @@ RUN apt-get update -q --fix-missing && \ rsyslog \ sasl2-bin \ spamassassin \ + supervisor \ postgrey \ unzip \ && \ @@ -133,6 +134,9 @@ COPY target/opendmarc/ignore.hosts /etc/opendmarc/ignore.hosts COPY target/fetchmail/fetchmailrc /etc/fetchmailrc_general RUN sed -i 's/START_DAEMON=no/START_DAEMON=yes/g' /etc/default/fetchmail +# Configure supervisor +COPY target/supervisor/supervisor-app.conf /etc/supervisor/conf.d/ + # Configures Postfix COPY target/postfix/main.cf target/postfix/master.cf /etc/postfix/ RUN echo "" > /etc/aliases && \ diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index 3cca7897..34a0df7a 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -1124,17 +1124,17 @@ function start_daemons() { function _start_daemons_cron() { notify 'task' 'Starting cron' 'n' - display_startup_daemon "cron" + supervisorctl start cron } function _start_daemons_rsyslog() { notify 'task' 'Starting rsyslog' 'n' - display_startup_daemon "/etc/init.d/rsyslog start" + supervisorctl start rsyslog } function _start_daemons_saslauthd() { notify 'task' 'Starting saslauthd' 'n' - display_startup_daemon "/etc/init.d/saslauthd start" + supervisorctl start saslauthd } function _start_daemons_fail2ban() { @@ -1144,28 +1144,28 @@ function _start_daemons_fail2ban() { if [ -e /var/run/fail2ban/fail2ban.sock ]; then rm /var/run/fail2ban/fail2ban.sock fi - display_startup_daemon "/etc/init.d/fail2ban start" + supervisorctl start fail2ban } function _start_daemons_opendkim() { notify 'task' 'Starting opendkim' 'n' - display_startup_daemon "/etc/init.d/opendkim start" + supervisorctl start opendkim } function _start_daemons_opendmarc() { notify 'task' 'Starting opendmarc' 'n' - display_startup_daemon "/etc/init.d/opendmarc start" + supervisorctl start opendmarc } function _start_daemons_postfix() { notify 'task' 'Starting postfix' 'n' - display_startup_daemon "/etc/init.d/postfix start" + supervisorctl start postfix } function _start_daemons_dovecot() { # Here we are starting sasl and imap, not pop3 because it's disabled by default notify 'task' 'Starting dovecot services' 'n' - display_startup_daemon "/usr/sbin/dovecot -c /etc/dovecot/dovecot.conf" + supervisorctl start dovecot if [ "$ENABLE_POP3" = 1 ]; then notify 'task' 'Starting pop3 services' 'n' @@ -1190,30 +1190,30 @@ function _start_daemons_dovecot() { function _start_daemons_filebeat() { notify 'task' 'Starting filebeat' 'n' - display_startup_daemon "/etc/init.d/filebeat start" + supervisorctl start filebeat } function _start_daemons_fetchmail() { notify 'task' 'Starting fetchmail' 'n' /usr/local/bin/setup-fetchmail - display_startup_daemon "/etc/init.d/fetchmail start" + supervisorctl start fetchmail } function _start_daemons_clamav() { notify 'task' 'Starting clamav' 'n' - display_startup_daemon "/etc/init.d/clamav-daemon start" + supervisorctl start clamav } function _start_daemons_postgrey() { notify 'task' 'Starting postgrey' 'n' rm -f /var/run/postgrey/postgrey.pid - display_startup_daemon "/etc/init.d/postgrey start" + supervisorctl start postgrey } function _start_daemons_amavis() { notify 'task' 'Starting amavis' 'n' - display_startup_daemon "/etc/init.d/amavis start" + supervisorctl start amavis } ########################################################################## @@ -1248,6 +1248,8 @@ notify 'taskgrp' "#" notify 'taskgrp' "#" notify 'taskgrp' "" +supervisord + register_functions check diff --git a/target/supervisor/supervisor-app.conf b/target/supervisor/supervisor-app.conf new file mode 100644 index 00000000..cfcacc4d --- /dev/null +++ b/target/supervisor/supervisor-app.conf @@ -0,0 +1,83 @@ +# each program entry below is a separate terminal command. +# Each command is expected to run in the foreground and stay running. +# If the command ever exits, the supervisor daemon will automatically run it again. +# Programs can be controlled like this: 'supervisorctl start fail2ban' 'supervisorctl stop fail2ban' +# supervisor writes program statuses in /var/log/supervisor + +[program:cron] +startsecs=0 +autostart=false +autorestart=true +command = /usr/sbin/cron + +[program:rsyslog] +startsecs=0 +autostart=false +autorestart=true +command = /etc/init.d/rsyslog start + +[program:saslauthd] +startsecs=0 +autostart=false +autorestart=true +command = /etc/init.d/saslauthd start + +[program:fail2ban] +startsecs=0 +autostart=false +autorestart=true +command = /etc/init.d/fail2ban start + +[program:opendkim] +startsecs=0 +autostart=false +autorestart=true +command = /etc/init.d/opendkim start + +[program:opendmarc] +startsecs=0 +autostart=false +autorestart=true +command = /etc/init.d/opendmarc start + +[program:postfix] +startsecs=0 +autostart=false +autorestart=true +command = /etc/init.d/postfix start + +[program:dovecot] +startsecs=0 +autostart=false +autorestart=true +command = /usr/sbin/dovecot -c /etc/dovecot/dovecot.conf + +[program:filebeat] +startsecs=0 +autostart=false +autorestart=true +command = /etc/init.d/filebeat start + +[program:fetchmail] +startsecs=0 +autostart=false +autorestart=true +command = /etc/init.d/fetchmail start + +[program:clamav] +startsecs=0 +autostart=false +autorestart=true +command = /etc/init.d/clamav-daemon start + +[program:postgrey] +startsecs=0 +autostart=false +autorestart=true +command = /etc/init.d/postgrey start + +[program:amavis] +startsecs=0 +autostart=false +autorestart=true +command = /etc/init.d/amavis start