mirror of
				https://github.com/uklans/cache-domains
				synced 2025-11-04 08:38:52 +01:00 
			
		
		
		
	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:
		
							parent
							
								
									019ec04f27
								
							
						
					
					
						commit
						84e9a378b3
					
				@ -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
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user