* Update check-for-changes.sh * add postfix-aliases.cf and handling of runtime updates
This commit is contained in:
parent
53a344a056
commit
30ed8fbf0e
|
@ -15,13 +15,16 @@ if [ ! -f postfix-accounts.cf ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# create an array of files to monitor (perhaps simple *.cf would be ok here)
|
||||||
|
declare -a cf_files=()
|
||||||
|
for file in postfix-accounts.cf postfix-virtual.cf postfix-aliases.cf; do
|
||||||
|
[ -f "$file" ] && cf_files+=("$file")
|
||||||
|
done
|
||||||
|
|
||||||
# Update / generate after start
|
# Update / generate after start
|
||||||
echo "${log_date} Makeing new checksum file."
|
echo "${log_date} Makeing new checksum file."
|
||||||
if [ -f postfix-virtual.cf ]; then
|
sha512sum ${cf_files[@]/#/--tag } > chksum
|
||||||
sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum
|
|
||||||
else
|
|
||||||
sha512sum --tag postfix-accounts.cf > chksum
|
|
||||||
fi
|
|
||||||
# Run forever
|
# Run forever
|
||||||
while true; do
|
while true; do
|
||||||
|
|
||||||
|
@ -30,15 +33,17 @@ log_date=$(date +"%Y-%m-%d %H:%M:%S ")
|
||||||
|
|
||||||
# Get chksum and check it.
|
# Get chksum and check it.
|
||||||
chksum=$(sha512sum -c --ignore-missing chksum)
|
chksum=$(sha512sum -c --ignore-missing chksum)
|
||||||
resu_acc=${chksum:21:2}
|
|
||||||
if [ -f postfix-virtual.cf ]; then
|
|
||||||
resu_vir=${chksum:44:2}
|
|
||||||
else
|
|
||||||
resu_vir="OK"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! [ $resu_acc = "OK" ] || ! [ $resu_vir = "OK" ]; then
|
if [[ $chksum == *"FAIL"* ]]; then
|
||||||
echo "${log_date} Change detected"
|
echo "${log_date} Change detected"
|
||||||
|
|
||||||
|
#regen postix aliases.
|
||||||
|
echo "root: ${POSTMASTER_ADDRESS}" > /etc/aliases
|
||||||
|
if [ -f /tmp/docker-mailserver/postfix-aliases.cf ]; then
|
||||||
|
cat /tmp/docker-mailserver/postfix-aliases.cf>>/etc/aliases
|
||||||
|
fi
|
||||||
|
postalias /etc/aliases
|
||||||
|
|
||||||
#regen postfix accounts.
|
#regen postfix accounts.
|
||||||
echo -n > /etc/postfix/vmailbox
|
echo -n > /etc/postfix/vmailbox
|
||||||
echo -n > /etc/dovecot/userdb
|
echo -n > /etc/dovecot/userdb
|
||||||
|
@ -169,11 +174,7 @@ if ! [ $resu_acc = "OK" ] || ! [ $resu_vir = "OK" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${log_date} Update checksum"
|
echo "${log_date} Update checksum"
|
||||||
if [ -f postfix-virtual.cf ]; then
|
sha512sum ${cf_files[@]/#/--tag } > chksum
|
||||||
sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum
|
|
||||||
else
|
|
||||||
sha512sum --tag postfix-accounts.cf > chksum
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
|
@ -778,6 +778,12 @@ function _setup_postfix_aliases() {
|
||||||
|
|
||||||
notify 'inf' "Configuring root alias"
|
notify 'inf' "Configuring root alias"
|
||||||
echo "root: ${POSTMASTER_ADDRESS}" > /etc/aliases
|
echo "root: ${POSTMASTER_ADDRESS}" > /etc/aliases
|
||||||
|
if [ -f /tmp/docker-mailserver/postfix-aliases.cf ]; then
|
||||||
|
cat /tmp/docker-mailserver/postfix-aliases.cf>>/etc/aliases
|
||||||
|
else
|
||||||
|
notify 'inf' "'config/postfix-aliases.cf' is not provided and will be auto created."
|
||||||
|
echo -n >/tmp/docker-mailserver/postfix-aliases.cf
|
||||||
|
fi
|
||||||
postalias /etc/aliases
|
postalias /etc/aliases
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue