#!/bin/bash dirs=( /var/run/clamav /var/log/clamav /var/log/opendkim /var/spool/postfix/opendkim /var/lib/clamav ) for dir in "${dirs[@]}"; do if [[ ! -d "${dir}" ]]; then mkdir -p "${dir}" fi chmod a+rwX -R "${dir}" done if [[ -e /var/run/dovecot/master.pid ]]; then rm /var/run/dovecot/master.pid fi if false; then # host accounts into the container PAM files for file in passwd group shadow gshadow; do cp "/etc/${file}" "/etc/${file}.container" while IFS= read -r account; do id="${account%%:*}" id="${account%%:*}" if ! grep -q "^${id}:" "/etc/${file}"; then echo "${account}" >> "/etc/${file}" fi done < "/etc/system${file}" done sed -i -E 's,(passwd|group|shadow|gshadow):.*files$,\1: files [NOTFOUND=return] system\1: files,g' /etc/nsswitch.conf else # use ldap sed -i -E 's#^base dc=example.*#base dc=ketrenos,dc=net#g' /etc/ldap.conf sed -i -E 's#^uri ldap.*#uri ldap://192.168.1.78/#g' /etc/ldap.conf sed -i -E 's#(passwd|group|shadow|gshadow):.*files$#\1: files ldap#g' /etc/nsswitch.conf fi while true; do /usr/sbin/opendkim -x /etc/opendkim.conf -f echo "opendkim died: $?" sleep 5 done & while true; do /usr/sbin/dovecot -F echo "dovecot died: $?" sleep 5 done & while true; do /usr/sbin/milter-greylist -D -P /var/run/greylist.pid -u postfix -p /var/spool/postfix/milter-greylist/milter-greylist.sock echo "milter-greylist died: $?" sleep 5 done & while true; do /usr/sbin/amavisd-new foreground echo "amavisd-new died: $?" sleep 5 done & while true; do /usr/sbin/postfix start-fg #/usr/lib/postfix/sbin/master -w echo "postfix died: $?" sleep 5 done & #while true; do # /usr/bin/python /usr/lib/mailman/bin/mailmanctl -s start # echo "mailmain died: $?" # sleep 5 #done & while true; do /usr/sbin/clamd --foreground=true echo "clamd died: $?" sleep 5 done & while true; do /usr/bin/freshclam -d --foreground=true echo "freshclam died: $?" sleep 5 done & while true; do /usr/bin/perl -T -w /usr/sbin/spamd --pidfile=/var/run/spamd.pid --create-prefs --max-children 5 --helper-home-dir --ipv4-only echo "spamd died: $?" sleep 5 done & # # Watch for letsencrypt changes and if they occur, restart nginx and apache2 # while inotifywait -e modify /etc/letsencrypt/archive; do kill -9 "$(cat /var/run/amavis/amavisd.pid)" "$(cat /var/run/dovecot/master.pid)" "$(cat /var/spool/postfix/pid/master.pid)" done