mirror of
https://github.com/bol-van/zapret.git
synced 2024-12-23 23:04:23 +00:00
26 lines
463 B
Bash
26 lines
463 B
Bash
|
#!/bin/sh
|
||
|
# create ipset from resolved ip's
|
||
|
|
||
|
SCRIPT=$(readlink -f $0)
|
||
|
EXEDIR=$(dirname $SCRIPT)
|
||
|
|
||
|
. "$EXEDIR/def.sh"
|
||
|
|
||
|
TEMPIPSET=/tmp/ipset.$ZIPSET.tmp
|
||
|
|
||
|
ipset flush $ZIPSET || ipset create $ZIPSET hash:ip
|
||
|
|
||
|
for f in "$ZIPLIST" "$ZIPLIST_USER"
|
||
|
do
|
||
|
[ -f $TEMPIPSET ] && rm -f $TEMPIPSET
|
||
|
[ -n "$f" ] && {
|
||
|
echo Adding $f
|
||
|
sort $f | uniq | while read ip;
|
||
|
do
|
||
|
echo add $ZIPSET $ip >>$TEMPIPSET
|
||
|
done
|
||
|
ipset -! restore <$TEMPIPSET 2>&1
|
||
|
rm -f $TEMPIPSET
|
||
|
}
|
||
|
done
|