Validate fetchmailrc MDA and allow for CA certificates to be added on /config

This commit is contained in:
Frederick Ding 2015-07-30 22:39:54 -04:00
parent 9ea87383ab
commit 95f72b5ba3

View File

@ -3,6 +3,7 @@
# verify maildir # verify maildir
if [ -d /var/mail/working ]; then if [ -d /var/mail/working ]; then
echo "/var/mail/working exists" echo "/var/mail/working exists"
chown -r root /var/mail/working
else else
maildirmake /var/mail/working maildirmake /var/mail/working
echo "to /var/mail/working" > /root/.mailfilter echo "to /var/mail/working" > /root/.mailfilter
@ -11,10 +12,26 @@ fi
# check for user config fetchmailrc # check for user config fetchmailrc
if [ -f /config/.fetchmailrc ]; then if [ -f /config/.fetchmailrc ]; then
cp /config/.fetchmailrc /root/.fetchmailrc cp /config/.fetchmailrc /root/.fetchmailrc
# ensure maildrop is the MDA
if grep --quiet '^mda "/usr/bin/maildrop"' /root/.fetchmailrc; then
echo "MDA correctly configured"
else
if grep --quiet '^mda' /root/.fetchmailrc; then
sed -i 's/mda.*/mda "\/usr\/bin\/maildrop"/' /root/.fetchmailrc
else
echo 'mda "/usr/bin/maildrop"' >> /root/.fetchmailrc
fi
chmod 0700 /root/.fetchmailrc chmod 0700 /root/.fetchmailrc
echo "Installed .fetchmailrc" echo "Installed .fetchmailrc"
fi fi
# update CA certificates if necessary from /config/*.crt
if stat --printf='' /config/*.crt 2>/dev/null
then
cp -v /config/*.crt /usr/local/share/ca-certificates/
update-ca-certificates
fi
if [ "$1" = 'cron' ] || [ "$1" = '/opt/save-attachments.sh' ]; then if [ "$1" = 'cron' ] || [ "$1" = '/opt/save-attachments.sh' ]; then
if [ ! -f /root/.fetchmailrc ]; then if [ ! -f /root/.fetchmailrc ]; then
echo "Cannot start container without .fetchmailrc" echo "Cannot start container without .fetchmailrc"