diff --git a/scripts/create-dnsmasq.sh b/scripts/create-dnsmasq.sh index b3e054d..8fe1e66 100755 --- a/scripts/create-dnsmasq.sh +++ b/scripts/create-dnsmasq.sh @@ -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 diff --git a/scripts/create-unbound.sh b/scripts/create-unbound.sh index 32f64c3..3507167 100755 --- a/scripts/create-unbound.sh +++ b/scripts/create-unbound.sh @@ -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)