install_opendmarc.sh: some minor fixes.
This commit is contained in:
parent
2222b9b6f3
commit
fabd9fc11f
@ -47,6 +47,7 @@ done
|
||||
postfix_needs_restart=false
|
||||
opendmarc_needs_restart=false
|
||||
|
||||
backup_date="$(date +%Y-%m-%d-%H%M)"
|
||||
log_file="$(mktemp)"
|
||||
|
||||
# -------------
|
||||
@ -362,7 +363,6 @@ fi
|
||||
# - Edit /etc/postfix/main.cf and add a section to activate
|
||||
# - processing of e-mail through the opendmarc daemon:
|
||||
# -
|
||||
backup_date="$(date +%Y-%m-%d-%H%M)"
|
||||
echononl " Backup existing postfix configuration (main.cf).."
|
||||
cp -a /etc/postfix/main.cf /etc/postfix/main.cf.$backup_date 2> $log_file
|
||||
if [[ $? -eq 0 ]] ; then
|
||||
@ -374,7 +374,7 @@ fi
|
||||
|
||||
echononl " Set Variable non_smtpd_milters at '/etc/postfix/main.cf'.."
|
||||
if $(grep -q -E "^\s*non_smtpd_milters\s*=\s*.*opendkim.sock" /etc/postfix/main.cf 2> /dev/null) ; then
|
||||
if $(grep -q -E "^\s*non_smtpd_milters\s*=\s*.*${opendmarc_socket_file}" /etc/postfix/main.cf); then
|
||||
if $(grep -q -E "^\s*non_smtpd_milters\s*=\s*.*$(basename "${opendmarc_socket_file}")" /etc/postfix/main.cf); then
|
||||
echo_skipped
|
||||
else
|
||||
perl -i -n -p -e "s&^\s*(non_smtpd_milters\s*=.*opendkim.sock)&\1,local:/$(basename "${opendmarc_socket_dir}")/$(basename "${opendmarc_socket_file}")&" \
|
||||
@ -409,7 +409,7 @@ fi
|
||||
# - -o smtpd_milters=local:/opendmarc/opendmarc.sock
|
||||
# -
|
||||
echononl " Backup file '/etc/postfix/master.cf'.."
|
||||
cp -a /etc/postfix/master.cf /etc/postfix/master.cf.$backup_date 2> $log_file
|
||||
cp -a /etc/postfix/master.cf /etc/postfix/master.cf.${backup_date} 2> $log_file
|
||||
if [[ $? -eq 0 ]] ; then
|
||||
echo_ok
|
||||
else
|
||||
@ -503,6 +503,21 @@ else
|
||||
echo_skipped
|
||||
fi
|
||||
|
||||
echo ""
|
||||
if [[ -f "/etc/postfix/master.cf.${backup_date}" ]] ; then
|
||||
if $(diff "/etc/postfix/master.cf" "/etc/postfix/master.cf.${backup_date}"> /dev/null 2>&1) ; then
|
||||
info "File \033[1m/etc/postfix/master.cf\033[m has not changed.\n\t Removing previos created backup.."
|
||||
rm "/etc/postfix/master.cf.${backup_date}"
|
||||
fi
|
||||
fi
|
||||
if [[ -f "/etc/postfix/main.cf.${backup_date}" ]] ; then
|
||||
if $(diff "/etc/postfix/main.cf" "/etc/postfix/main.cf.${backup_date}"> /dev/null 2>&1) ; then
|
||||
info "File \033[1m/etc/postfix/main.cf\033[m has not changed.\n\t Removing previos created backup.."
|
||||
rm "/etc/postfix/main.cf.${backup_date}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo ""
|
||||
rm -f "$log_file"
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user