File tree Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
2- # add_whitelists.sh - Add domains/IPs to Postfix and Postgrey whitelists
3- # Author: Anton Babaskin
4-
52set -Eeuo pipefail
63
74POSTFIX_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
2718EOF
2819 exit 1
2920}
@@ -94,7 +85,8 @@ is_cidr() {
9485}
9586
9687already_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
You can’t perform that action at this time.
0 commit comments