Skip to content

Commit 24bf008

Browse files
add_whitelists.sh
1 parent 9bec7ce commit 24bf008

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

add_whitelists.sh

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#!/usr/bin/env bash
2-
# add_whitelists.sh - Add domains/IPs to Postfix and Postgrey whitelists
3-
# Author: Anton Babaskin
4-
52
set -Eeuo pipefail
63

74
POSTFIX_FILE="/etc/postfix/client_whitelist"
@@ -18,12 +15,6 @@ Options:
1815
-f FILE File with entries (one per line, empty lines and #comments ignored)
1916
-n Dry-run mode (no changes applied)
2017
-h Show this help message
21-
22-
Examples:
23-
$0 example.com
24-
$0 203.0.113.7
25-
$0 -f whitelist.txt
26-
$0 -n -f whitelist.txt
2718
EOF
2819
exit 1
2920
}
@@ -94,7 +85,8 @@ is_cidr() {
9485
}
9586

9687
already_in_file() {
97-
local needle="$1" file="$2"
88+
local needle="$1"
89+
local file="$2"
9890
grep -qE -- "^${needle//./\\.}([[:space:]]|$)" "$file"
9991
}
10092

@@ -140,7 +132,7 @@ process_entry() {
140132
[[ "$entry" =~ ^# ]] && return 0
141133

142134
if is_cidr "$entry"; then
143-
msg "⚠️ CIDR '$entry' not supported in hash map. Use a CIDR map instead."
135+
msg "⚠️ CIDR '$entry' not supported in hash map."
144136
return 0
145137
elif is_ipv4 "$entry"; then
146138
add_postfix "$entry" && CHANGED_POSTFIX=1 || true

0 commit comments

Comments
 (0)