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:
parent
aaeb4a56fc
commit
a402bc4882
1 changed files with 16 additions and 1 deletions
|
|
@ -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:-}
|
||||
|
||||
savext=${savext:-.save}
|
||||
|
||||
db=${db:-name-maxelem.db}
|
||||
|
||||
dbtmp=${dbtmp:-$db.tmp}
|
||||
|
||||
ipset=${ipset:-$(which ipset)}
|
||||
ipsetcmd=${ipsetcmd:-restore}
|
||||
|
||||
scriptdir=${scriptdir:-$(dirname $0)}
|
||||
savecnt="${scriptdir}/save-count.pl"
|
||||
sortcnt="${scriptdir}/combine-counts.pl"
|
||||
|
|
@ -40,6 +51,10 @@ loadset="${scriptdir}/combine-saves.pl"
|
|||
|
||||
files=${files:-"$@"}
|
||||
|
||||
if test -n "$check" ; then
|
||||
check="--check=$checkdef";
|
||||
fi
|
||||
|
||||
if test -z "$files" ; then
|
||||
files=$(ls -1 ${folder}*${savext} 2>/dev/null)
|
||||
fi
|
||||
|
|
@ -53,7 +68,7 @@ cat "$files" | \
|
|||
$savecnt >$dbtmp \
|
||||
&& $sortcnt <$dbtmp >$db \
|
||||
&& cat "$files" \
|
||||
| $loadset $db \
|
||||
| $loadset $check $db \
|
||||
| $ipset $ipsetcmd
|
||||
RV=$?
|
||||
rm -f $dbtmp 2>/dev/null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue