jina verze
This commit is contained in:
@@ -113,10 +113,6 @@ EOF
|
||||
function cmdPostfixInit() {
|
||||
printSection "Initialization..."
|
||||
|
||||
touch "$postfixConfigPath/$postfixDomainsFile" || return 1
|
||||
touch "$postfixConfigPath/$postfixAliasesFile" || return 1
|
||||
touch "$postfixConfigPath/$postfixSendersFile" || return 1
|
||||
|
||||
postfixDkimAdd "$postfixHost" || {
|
||||
printDotText "Add DKIM for host" "$labelFail"
|
||||
return 1
|
||||
@@ -150,20 +146,6 @@ function cmdPostfixUninstall() {
|
||||
"$k3sCmd" kubectl delete -f "$postfixYaml"
|
||||
}
|
||||
|
||||
function cmdPostfixUser() {
|
||||
local output error
|
||||
|
||||
printRow
|
||||
|
||||
if ! run output error postfixUserList; then
|
||||
printDanger "$error"
|
||||
elif [[ -z "$output" ]]; then
|
||||
printText "$labelNull"
|
||||
else
|
||||
printText "$output"
|
||||
fi
|
||||
}
|
||||
|
||||
# Prints the Postfix mail version.
|
||||
function cmdPostfixInfo() {
|
||||
local output error podList ver pid
|
||||
@@ -208,69 +190,123 @@ function cmdPostfixInfo() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Sets a virtual alias forward-to address for a domain and saves it to site config.
|
||||
# $1 (domain): site domain name.
|
||||
# $2 (mail): forward-to email address.
|
||||
function cmdPostfixVirtualAliasSetEx() {
|
||||
local domain="$1"
|
||||
[[ -n "$domain" ]] || { printDanger "$postfixLabel Domain not specified"; return 1; }
|
||||
local mail="$2"
|
||||
[[ -n "$mail" ]] || { printDanger "$postfixLabel Mail not specified"; return 1; }
|
||||
|
||||
local domainList output error
|
||||
if ! run domainList error postfixDomainList; then
|
||||
printDanger "$postfixLabel postfixDomainList: $error"
|
||||
return 1
|
||||
elif ! listContains "$domain" "$domainList"; then
|
||||
printDanger "$postfixLabel Domain not found in postfixDomainList"
|
||||
return 1
|
||||
elif ! run output error siteConfigSet "$domain" "postfixForwardTo" "$mail"; then
|
||||
printDanger "$postfixLabel siteConfigSet: $error"
|
||||
elif ! run output error postfixVirtualAliasSet "@$domain" "$mail"; then
|
||||
printDanger "$postfixLabel postfixVirtualAliasSet: $error"
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks MTA host DNS records (A, SPF, PTR, DKIM) against configured values.
|
||||
function cmdPostfixMtaDnsCheck() {
|
||||
local label output error text
|
||||
|
||||
printSection "MTA DNS: $postfixHost"
|
||||
|
||||
# A record
|
||||
if ! run output error dig +short A "$postfixHost" "$dnsResolver"; then
|
||||
printDotText "A record" "$fontRed${output:-$error}$fontReset"
|
||||
label="$postfixLabel A record: $postfixHost"
|
||||
if ! run output error dig +short A "$postfixHost" "$postfixResolver"; then
|
||||
printDanger "$label"
|
||||
else
|
||||
text=$(printf '%s' "$output" | paste -sd, - | sed 's/,/ \/ /g')
|
||||
if grep -Fxq -- "$postfixIp" <<<"$output"; then
|
||||
printDotText "A record" "$fontGreen$text$fontReset"
|
||||
printSuccess "$label | $text"
|
||||
else
|
||||
printDotText "A record" "$fontYellow$text$fontReset"
|
||||
printWarning "$label | $text"
|
||||
fi
|
||||
fi
|
||||
|
||||
# SPF record
|
||||
if ! run output error dig +short TXT "$postfixHost" "$dnsResolver"; then
|
||||
printDotText "SPF record" "$fontRed${output:-$error}$fontReset"
|
||||
label="$postfixLabel SPF record: $postfixHost"
|
||||
if ! run output error dig +short TXT "$postfixHost" "$postfixResolver"; then
|
||||
printDanger "$label"
|
||||
elif grep -Eq '^"?v=spf1([[:space:]]|")' <<<"$output"; then
|
||||
printDotText "SPF record" "$fontGreen$output$fontReset"
|
||||
printSuccess "$label | $output"
|
||||
else
|
||||
printDotText "SPF record" "$fontRed$output$fontReset"
|
||||
printWarning "$label | $output"
|
||||
fi
|
||||
|
||||
# PTR record
|
||||
if ! run output error dig -x "$postfixIp" +short "$dnsResolver"; then
|
||||
printDotText "PTR record" "$fontRed${output:-$error}$fontReset"
|
||||
label="$postfixLabel PTR record: $postfixHost"
|
||||
if ! run output error dig -x "$postfixIp" +short "$postfixResolver"; then
|
||||
printDanger "$label"
|
||||
else
|
||||
text=$(printf '%s' "$output" | paste -sd, - | sed 's/,/ \/ /g')
|
||||
if grep -Fxq -- "$postfixHost." <<<"$output"; then
|
||||
printDotText "PTR record" "$fontGreen$text$fontReset"
|
||||
printSuccess "$label | $text"
|
||||
else
|
||||
printDotText "PTR record" "$fontYellow$text$fontReset"
|
||||
printWarning "$label | $text"
|
||||
fi
|
||||
fi
|
||||
|
||||
# DKIM record
|
||||
label="$postfixLabel DKIM record: $postfixHost"
|
||||
if ! run output error dig +short TXT "$postfixDkimSelector._domainkey.$postfixHost"; then
|
||||
printDotText "DKIM record" "$fontRed${output:-$error}$fontReset"
|
||||
printDanger "$label | $error"
|
||||
else
|
||||
local dkimDnsNorm dkimFileRaw dkimFileNorm
|
||||
dkimDnsNorm=$(
|
||||
printf '%s\n' "$output" |
|
||||
tr -d '\n' |
|
||||
sed -e 's/"//g' -e 's/[[:space:]]//g' |
|
||||
sed -n 's/.*p=\([^;]*\).*/\1/p'
|
||||
printf '%s\n' "$output" |
|
||||
tr -d '\n' |
|
||||
sed -e 's/"//g' -e 's/[[:space:]]//g' |
|
||||
sed -n 's/.*p=\([^;]*\).*/\1/p'
|
||||
)
|
||||
|
||||
dkimFileRaw=$(postfixDkimGet "$postfixHost")
|
||||
dkimFileNorm=$(
|
||||
printf '%s\n' "$dkimFileRaw" |
|
||||
tr -d '\n' |
|
||||
sed -e 's/[()"]//g' -e 's/[[:space:]]//g' |
|
||||
sed -n 's/.*p=\([^;]*\).*/\1/p'
|
||||
printf '%s\n' "$dkimFileRaw" |
|
||||
tr -d '\n' |
|
||||
sed -e 's/[()"]//g' -e 's/[[:space:]]//g' |
|
||||
sed -n 's/.*p=\([^;]*\).*/\1/p'
|
||||
)
|
||||
|
||||
if [[ "$dkimDnsNorm" == "$dkimFileNorm" ]]; then
|
||||
printText "$fontGreen$dkimDnsNorm$fontReset"
|
||||
printSuccess "$label | OK"
|
||||
else
|
||||
printText "DNS : $fontYellow$dkimDnsNorm$fontReset"
|
||||
printText "File: $fontYellow$dkimFileNorm$fontReset"
|
||||
printWarning "$label | DNS : $dkimDnsNorm"
|
||||
printWarning "$label | FILE: $dkimFileNorm"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Prints domain/alias/sender/SASL lists; accepts domain/alias/senders/sasl as filter.
|
||||
# [$1] (filter): domain|alias|senders|sasl; omit to print all.
|
||||
function cmdPostfixList() {
|
||||
case "$1" in
|
||||
'domain')
|
||||
postfixDomainList
|
||||
;;
|
||||
'alias')
|
||||
postfixAliasList
|
||||
;;
|
||||
'senders')
|
||||
postfixSendersList
|
||||
;;
|
||||
'sasl')
|
||||
postfixSaslUserList
|
||||
;;
|
||||
*)
|
||||
printInfo "$postfixLabel Domains"
|
||||
postfixDomainList
|
||||
|
||||
printInfo "$postfixLabel Aliases"
|
||||
postfixAliasList
|
||||
|
||||
printInfo "$postfixLabel Senders"
|
||||
postfixSendersList
|
||||
|
||||
printInfo "$postfixLabel SASL users"
|
||||
postfixSaslUserList
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user