#!/bin/bash ((EUID == 0 )) || { echo "Need root"; exit 1; } set -euo pipefail CONFD=/etc/e-router source $CONFD/config tmp=$(mktemp) trap "/bin/rm -f ${tmp}" EXIT SIGHUP SIGINT SIGTERM if curl -f -s -S -m 60 -o $tmp "https://www.badips.com/get/list/${badservice}/${badlevel}?age=${badrange}" ; then while read -r ip ; do [[ "$ip" =~ ^[0-9]{1,}.[0-9]{1,}.[0-9]{1,}.[0-9]{1,}$ ]] && ipset -! add ${badset} ${ip} timeout $badttl done < $tmp fi if curl -f -s -S -m 60 -o $tmp "http://api.blocklist.de/getlast.php?time=7200&service=all" ; then while read -r ip ; do [[ "$ip" =~ ^[0-9]{1,}.[0-9]{1,}.[0-9]{1,}.[0-9]{1,}$ ]] && ipset -! add ${badset} ${ip} timeout $badttl done < $tmp fi