mirror of
https://github.com/bol-van/zapret.git
synced 2024-12-02 14:40:52 +03:00
27 lines
610 B
Bash
Executable File
27 lines
610 B
Bash
Executable File
#!/bin/sh
|
|
# create ipset from resolved ip's
|
|
|
|
SCRIPT=$(readlink -f $0)
|
|
EXEDIR=$(dirname $SCRIPT)
|
|
|
|
. "$EXEDIR/def.sh"
|
|
|
|
create_ipset()
|
|
{
|
|
ipset flush $1 2>/dev/null || ipset create $1 hash:ip
|
|
for f in "$2" "$3"
|
|
do
|
|
[ -f "$f" ] && {
|
|
echo Adding to ipset $1 : $f
|
|
if [ -f "$ZIPLIST_EXCLUDE" ] ; then
|
|
grep -vxFf $ZIPLIST_EXCLUDE "$f" | sort -u | while read ip; do echo add $1 $ip; done | ipset -! restore
|
|
else
|
|
sort -u "$f" | while read ip; do echo add $1 $ip; done | ipset -! restore
|
|
fi
|
|
}
|
|
done
|
|
}
|
|
|
|
create_ipset $ZIPSET $ZIPLIST $ZIPLIST_USER
|
|
create_ipset $ZIPSET_IPBAN $ZIPLIST_IPBAN $ZIPLIST_USER_IPBAN
|