From 45c1f286a608e76281dff5ebb0a541d0d27edc1e Mon Sep 17 00:00:00 2001 From: LukeAllen Date: Fri, 2 Jun 2017 21:45:47 -0700 Subject: [PATCH] installed supervisor. Still need to set tasks to run in foreground. --- Dockerfile | 4 ++ target/start-mailserver.sh | 28 ++++----- target/supervisor/supervisor-app.conf | 83 +++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 13 deletions(-) create mode 100644 target/supervisor/supervisor-app.conf diff --git a/Dockerfile b/Dockerfile index 5eb466e1..7721dbcf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,6 +49,7 @@ RUN apt-get update -q --fix-missing && \ rsyslog \ sasl2-bin \ spamassassin \ + supervisor \ postgrey \ unzip \ && \ @@ -121,6 +122,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 94bddb6c..972a4ecb 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -1129,17 +1129,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() { @@ -1149,28 +1149,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' @@ -1195,29 +1195,29 @@ 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' - 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 } ########################################################################## @@ -1252,6 +1252,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