144 lines
3.3 KiB
Bash
Executable File
144 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# clamav needs access to read the spool files from amavis
|
|
usermod -a -G amavis clamav
|
|
|
|
# postfix needs access to the opendkim socket
|
|
usermod -a -G opendkim postfix
|
|
|
|
chmod g+rx /var/lib/amavis/tmp
|
|
|
|
dirs=(
|
|
/var/log/clamav
|
|
/var/log/opendkim
|
|
/var/lib/clamav
|
|
/var/lib/amavis
|
|
)
|
|
#for dir in "${dirs[@]}"; do
|
|
# if [[ ! -d "${dir}" ]]; then
|
|
# mkdir -p "${dir}"
|
|
# fi
|
|
# chmod a+rwX -R "${dir}"
|
|
#done
|
|
|
|
# directory is not being created by /etc/init.d/opendkim
|
|
mkdir /var/spool/postfix/opendkim
|
|
chown opendkim:opendkim /var/spool/postfix/opendkim
|
|
|
|
chown root:root /var/log
|
|
for log in syslog "mail.*" "dovecot*.log" auth.log; do
|
|
touch /var/log/${log}
|
|
chmod a+rwX /var/log/${log}
|
|
done
|
|
|
|
if [[ -e /run/rsyslogd.pid ]]; then
|
|
rm /run/rsyslogd.pid
|
|
fi
|
|
|
|
if [[ -e /var/run/dovecot/master.pid ]]; then
|
|
rm /var/run/dovecot/master.pid
|
|
fi
|
|
|
|
# Set opendkim.sock ownership and permissions
|
|
|
|
find /var/log -name 'dovecot*' | while read -r file; do
|
|
chown dovecot:postfix "${file}"
|
|
chmod g+rwX "${file}"
|
|
done
|
|
|
|
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/rsyslogd -n
|
|
echo "rsyslogd died: $?"
|
|
sleep 5
|
|
done &
|
|
|
|
/etc/init.d/opendkim start
|
|
#while true; do
|
|
# /usr/sbin/opendkim -x /etc/opendkim.conf -f
|
|
# echo "opendkim died: $?"
|
|
# sleep 5
|
|
#done &
|
|
|
|
/etc/init.d/dovecot start
|
|
#while true; do
|
|
# /usr/sbin/dovecot -F
|
|
# echo "dovecot died: $?"
|
|
# sleep 5
|
|
#done &
|
|
|
|
/etc/init.d/milter-greylist start
|
|
#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 &
|
|
|
|
/etc/init.d/amavis start
|
|
#while true; do
|
|
# /usr/sbin/amavisd-new foreground
|
|
# echo "amavisd-new died: $?"
|
|
# sleep 5
|
|
#done &
|
|
|
|
#while true; do
|
|
# /usr/bin/python /usr/lib/mailman/bin/mailmanctl -s start
|
|
# echo "mailmain died: $?"
|
|
# sleep 5
|
|
#done &
|
|
|
|
/etc/init.d/clamav-daemon start
|
|
#while true; do
|
|
# /usr/sbin/clamd --foreground=true
|
|
# echo "clamd died: $?"
|
|
# sleep 5
|
|
#done &
|
|
|
|
/etc/init.d/clamav-freshclam start
|
|
#while true; do
|
|
# /usr/bin/freshclam -d --foreground=true
|
|
# echo "freshclam died: $?"
|
|
# sleep 5
|
|
#done &
|
|
|
|
/etc/init.d/spamassassin start
|
|
#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 &
|
|
|
|
/etc/init.d/postfix start
|
|
#while true; do
|
|
# /usr/sbin/postfix start-fg
|
|
# echo "postfix died: $?"
|
|
# sleep 5
|
|
#done &
|
|
|
|
#
|
|
# Watch for letsencrypt changes and if they occur, restart nginx and apache2
|
|
#
|
|
while inotifywait -e modify /etc/letsencrypt/archive; do
|
|
/etc/init.d/dovecot restart
|
|
/etc/init.d/postfix restart
|
|
done
|