diff --git a/scripts/create-dnsmasq.sh b/scripts/create-dnsmasq.sh index 559fd59..abe94b0 100755 --- a/scripts/create-dnsmasq.sh +++ b/scripts/create-dnsmasq.sh @@ -50,32 +50,32 @@ while read -r entry; do touch "$outputfile" # Wildcard entries while read -r fileentry; do - # Ignore comments - if [[ $fileentry == \#* ]]; then + # Ignore comments and non-wildcards + if [[ $fileentry == \#* ]] || [[ ! $fileentry =~ ^\*\. ]]; then continue fi - wildcard=$(echo $fileentry | grep "*." | sed -e "s/^\*\.//") - if grep -q "$wildcard" "$lancacheconf"; then + wildcard=$(echo $fileentry | sed -e "s/^\*\.//") + if grep -qx "$wildcard" "$lancacheconf"; then continue fi for i in ${cacheip}; do echo "address=/${wildcard}/${i}" >> "$lancacheconf" done - done <<< $(cat ${basedir}/$filename); + done <<< $(cat ${basedir}/$filename | sort); # All other entries while read -r fileentry; do - # Ignore comments - if [[ $fileentry == \#* ]]; then + # Ignore comments and wildcards + if [[ $fileentry =~ ^(\#|\*\.) ]]; then continue fi - parsed=$(echo $fileentry | sed -e "s/^\*\.//") - if grep -q "$parsed" "$outputfile"; then + parsed=$(echo $fileentry) + if grep -qx "$parsed" "$outputfile"; then continue fi for i in ${cacheip}; do echo "${i} ${parsed}" >> "$outputfile" done - done <<< $(cat ${basedir}/$filename); + done <<< $(cat ${basedir}/$filename | sort); 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) diff --git a/scripts/create-unbound.sh b/scripts/create-unbound.sh index 10ee026..1364a47 100755 --- a/scripts/create-unbound.sh +++ b/scripts/create-unbound.sh @@ -52,14 +52,14 @@ while read entry; do continue fi parsed=$(echo $fileentry | sed -e "s/^\*\.//") - if grep -q "$parsed" $outputfile; then + if grep -qx "$parsed" $outputfile; then continue fi 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); + done <<< $(cat ${basedir}/$filename | sort); 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)