create-unbound.sh and create-unbound.sh will now ignore empty entries, which may result into corrupt config files causing at least unbound (and probably also dnsmasq) to fail starting up

https://github.com/uklans/cache-domains/issues/157
This commit is contained in:
Klaus 2021-01-17 19:42:17 +01:00
parent 019ec04f27
commit 84e9a378b3
No known key found for this signature in database
GPG Key ID: B3C20A4CEFE31610
2 changed files with 14 additions and 0 deletions

View File

@ -69,6 +69,10 @@ while read -r entry; do
continue
fi
parsed=$(echo $fileentry)
# Ignore empty lines
if [[ -z "$parsed" ]]; then
continue
fi
if grep -qx "$parsed" "$outputfile"; then
continue
fi

View File

@ -42,6 +42,7 @@ while read entry; do
cacheip=$(jq -r 'if type == "array" then .[] else . end' <<< ${!cacheipname} | xargs)
while read fileid; do
while read filename; do
isvalid=false
destfilename=$(echo $filename | sed -e 's/txt/conf/')
outputfile=${outputdir}/${destfilename}
touch $outputfile
@ -52,14 +53,23 @@ while read entry; do
continue
fi
parsed=$(echo $fileentry | sed -e "s/^\*\.//")
# Ignore empty lines
if [[ -z "$parsed" ]]; then
continue
fi
if grep -qx "$parsed" $outputfile; then
continue
fi
isvalid=true
echo " local-zone: \"${parsed}\" redirect" >> $outputfile
for i in ${cacheip}; do
echo " local-data: \"${parsed} 30 IN A ${i}\"" >> $outputfile
done
done <<< $(cat ${basedir}/$filename | sort);
# Delete files with no entries
if [[ $isvalid == false ]]; then
rm $outputfile
fi
done <<< $(jq -r ".cache_domains[$entry].domain_files[$fileid]" $path)
done <<< $(jq -r ".cache_domains[$entry].domain_files | to_entries[] | .key" $path)
done <<< $(jq -r '.cache_domains | to_entries[] | .key' $path)