installed supervisor. Still need to set tasks to run in foreground.

This commit is contained in:
LukeAllen 2017-06-02 21:45:47 -07:00 committed by Johan Smits
parent 60afbe1d16
commit 1858f8c0ce
3 changed files with 102 additions and 13 deletions

View File

@ -47,6 +47,7 @@ RUN apt-get update -q --fix-missing && \
rsyslog \ rsyslog \
sasl2-bin \ sasl2-bin \
spamassassin \ spamassassin \
supervisor \
postgrey \ postgrey \
unzip \ unzip \
&& \ && \
@ -133,6 +134,9 @@ COPY target/opendmarc/ignore.hosts /etc/opendmarc/ignore.hosts
COPY target/fetchmail/fetchmailrc /etc/fetchmailrc_general COPY target/fetchmail/fetchmailrc /etc/fetchmailrc_general
RUN sed -i 's/START_DAEMON=no/START_DAEMON=yes/g' /etc/default/fetchmail 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 # Configures Postfix
COPY target/postfix/main.cf target/postfix/master.cf /etc/postfix/ COPY target/postfix/main.cf target/postfix/master.cf /etc/postfix/
RUN echo "" > /etc/aliases && \ RUN echo "" > /etc/aliases && \

View File

@ -1124,17 +1124,17 @@ function start_daemons() {
function _start_daemons_cron() { function _start_daemons_cron() {
notify 'task' 'Starting cron' 'n' notify 'task' 'Starting cron' 'n'
display_startup_daemon "cron" supervisorctl start cron
} }
function _start_daemons_rsyslog() { function _start_daemons_rsyslog() {
notify 'task' 'Starting rsyslog' 'n' notify 'task' 'Starting rsyslog' 'n'
display_startup_daemon "/etc/init.d/rsyslog start" supervisorctl start rsyslog
} }
function _start_daemons_saslauthd() { function _start_daemons_saslauthd() {
notify 'task' 'Starting saslauthd' 'n' notify 'task' 'Starting saslauthd' 'n'
display_startup_daemon "/etc/init.d/saslauthd start" supervisorctl start saslauthd
} }
function _start_daemons_fail2ban() { function _start_daemons_fail2ban() {
@ -1144,28 +1144,28 @@ function _start_daemons_fail2ban() {
if [ -e /var/run/fail2ban/fail2ban.sock ]; then if [ -e /var/run/fail2ban/fail2ban.sock ]; then
rm /var/run/fail2ban/fail2ban.sock rm /var/run/fail2ban/fail2ban.sock
fi fi
display_startup_daemon "/etc/init.d/fail2ban start" supervisorctl start fail2ban
} }
function _start_daemons_opendkim() { function _start_daemons_opendkim() {
notify 'task' 'Starting opendkim' 'n' notify 'task' 'Starting opendkim' 'n'
display_startup_daemon "/etc/init.d/opendkim start" supervisorctl start opendkim
} }
function _start_daemons_opendmarc() { function _start_daemons_opendmarc() {
notify 'task' 'Starting opendmarc' 'n' notify 'task' 'Starting opendmarc' 'n'
display_startup_daemon "/etc/init.d/opendmarc start" supervisorctl start opendmarc
} }
function _start_daemons_postfix() { function _start_daemons_postfix() {
notify 'task' 'Starting postfix' 'n' notify 'task' 'Starting postfix' 'n'
display_startup_daemon "/etc/init.d/postfix start" supervisorctl start postfix
} }
function _start_daemons_dovecot() { function _start_daemons_dovecot() {
# Here we are starting sasl and imap, not pop3 because it's disabled by default # Here we are starting sasl and imap, not pop3 because it's disabled by default
notify 'task' 'Starting dovecot services' 'n' 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 if [ "$ENABLE_POP3" = 1 ]; then
notify 'task' 'Starting pop3 services' 'n' notify 'task' 'Starting pop3 services' 'n'
@ -1190,30 +1190,30 @@ function _start_daemons_dovecot() {
function _start_daemons_filebeat() { function _start_daemons_filebeat() {
notify 'task' 'Starting filebeat' 'n' notify 'task' 'Starting filebeat' 'n'
display_startup_daemon "/etc/init.d/filebeat start" supervisorctl start filebeat
} }
function _start_daemons_fetchmail() { function _start_daemons_fetchmail() {
notify 'task' 'Starting fetchmail' 'n' notify 'task' 'Starting fetchmail' 'n'
/usr/local/bin/setup-fetchmail /usr/local/bin/setup-fetchmail
display_startup_daemon "/etc/init.d/fetchmail start" supervisorctl start fetchmail
} }
function _start_daemons_clamav() { function _start_daemons_clamav() {
notify 'task' 'Starting clamav' 'n' notify 'task' 'Starting clamav' 'n'
display_startup_daemon "/etc/init.d/clamav-daemon start" supervisorctl start clamav
} }
function _start_daemons_postgrey() { function _start_daemons_postgrey() {
notify 'task' 'Starting postgrey' 'n' notify 'task' 'Starting postgrey' 'n'
rm -f /var/run/postgrey/postgrey.pid rm -f /var/run/postgrey/postgrey.pid
display_startup_daemon "/etc/init.d/postgrey start" supervisorctl start postgrey
} }
function _start_daemons_amavis() { function _start_daemons_amavis() {
notify 'task' 'Starting amavis' 'n' 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' "#"
notify 'taskgrp' "" notify 'taskgrp' ""
supervisord
register_functions register_functions
check check

View File

@ -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