update-list: Make zone-type dynamic

This commit is contained in:
Enno Tensing 2024-12-30 18:07:32 +01:00
parent bd2365c178
commit 8cb50fd264
Signed by: tenno
GPG key ID: 95265603BD36E66C

View file

@ -1,7 +1,8 @@
#!/bin/sh
TYPE="always-null"
CONFDIR="/etc/unbound"
CONFFILE="always-deny.conf"
CONFFILE="${TYPE}.conf"
CONF="${CONFDIR}/${CONFFILE}"
SOURCES="${CONFDIR}/sources"
BUILDDIR="$(openssl rand -hex 42)"
@ -29,10 +30,11 @@ format_sources()
{
cat domains | tr -d '|' | tr -d '^' | grep -v '#' | sed -e 's|0.0.0.0 ||g' | sort -u | uniq > new_domains
cat new_domains | while read -r domain
blocktype="$(printf '%b' "$TYPE" | sed -e 's|-|_|g')"
do
if ! [ -z "$domain" ]
then
printf 'local-zone: "%b" always_deny\n' "$domain"
printf 'local-zone: "%b" %b\n' "$domain" "$blocktype"
fi
done | tee "${CONF}"
}