2016-02-15 16:34:45 +03:00
|
|
|
#!/bin/sh
|
|
|
|
# create ipset from resolved ip's
|
|
|
|
|
|
|
|
SCRIPT=$(readlink -f $0)
|
|
|
|
EXEDIR=$(dirname $SCRIPT)
|
|
|
|
|
|
|
|
. "$EXEDIR/def.sh"
|
|
|
|
|
|
|
|
|
2016-03-04 12:03:34 +03:00
|
|
|
create_ipset()
|
|
|
|
{
|
|
|
|
ipset flush $1 2>/dev/null || ipset create $1 hash:ip
|
2016-02-15 16:34:45 +03:00
|
|
|
|
2016-03-04 12:03:34 +03:00
|
|
|
local TEMPIPSET=/tmp/ipset.$1.tmp
|
|
|
|
|
|
|
|
for f in "$2" "$3"
|
2016-02-15 16:34:45 +03:00
|
|
|
do
|
|
|
|
[ -f $TEMPIPSET ] && rm -f $TEMPIPSET
|
2016-03-04 12:03:34 +03:00
|
|
|
[ -f "$f" ] && {
|
|
|
|
echo Adding to ipset "$1" : $f
|
2016-03-16 08:48:14 +03:00
|
|
|
touch $TEMPIPSET
|
2016-02-15 16:34:45 +03:00
|
|
|
sort $f | uniq | while read ip;
|
|
|
|
do
|
2016-03-04 12:03:34 +03:00
|
|
|
echo add $1 $ip >>$TEMPIPSET
|
2016-02-15 16:34:45 +03:00
|
|
|
done
|
|
|
|
ipset -! restore <$TEMPIPSET 2>&1
|
|
|
|
rm -f $TEMPIPSET
|
|
|
|
}
|
|
|
|
done
|
2016-03-04 12:03:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
create_ipset $ZIPSET $ZIPLIST $ZIPLIST_USER
|
|
|
|
create_ipset $ZIPSET_IPBAN $ZIPLIST_IPBAN $ZIPLIST_USER_IPBAN
|