add IP deduplication optons

Add $check new variable taken from environment; it can be set to
an integeter to generate the apprprite option to combine-saves.pl
This commit is contained in:
Corwin Brust 2026-04-21 11:43:00 -05:00
parent aaeb4a56fc
commit a402bc4882

View file

@ -25,14 +25,25 @@
# #
################# #################
##
# options to control duplicate IP checks:
# 0 - no checking
# 1 - in restore, append -exist to ipset add
# 2 - in parse, run ipcheck test check
# 3 - in both restore and parse, exist & test
check=${check:-} # take default from combine-saves.pl
folder=${folder:-} folder=${folder:-}
savext=${savext:-.save} savext=${savext:-.save}
db=${db:-name-maxelem.db} db=${db:-name-maxelem.db}
dbtmp=${dbtmp:-$db.tmp} dbtmp=${dbtmp:-$db.tmp}
ipset=${ipset:-$(which ipset)} ipset=${ipset:-$(which ipset)}
ipsetcmd=${ipsetcmd:-restore} ipsetcmd=${ipsetcmd:-restore}
scriptdir=${scriptdir:-$(dirname $0)} scriptdir=${scriptdir:-$(dirname $0)}
savecnt="${scriptdir}/save-count.pl" savecnt="${scriptdir}/save-count.pl"
sortcnt="${scriptdir}/combine-counts.pl" sortcnt="${scriptdir}/combine-counts.pl"
@ -40,6 +51,10 @@ loadset="${scriptdir}/combine-saves.pl"
files=${files:-"$@"} files=${files:-"$@"}
if test -n "$check" ; then
check="--check=$checkdef";
fi
if test -z "$files" ; then if test -z "$files" ; then
files=$(ls -1 ${folder}*${savext} 2>/dev/null) files=$(ls -1 ${folder}*${savext} 2>/dev/null)
fi fi
@ -53,7 +68,7 @@ cat "$files" | \
$savecnt >$dbtmp \ $savecnt >$dbtmp \
&& $sortcnt <$dbtmp >$db \ && $sortcnt <$dbtmp >$db \
&& cat "$files" \ && cat "$files" \
| $loadset $db \ | $loadset $check $db \
| $ipset $ipsetcmd | $ipset $ipsetcmd
RV=$? RV=$?
rm -f $dbtmp 2>/dev/null rm -f $dbtmp 2>/dev/null