mirror of
				https://github.com/uklans/cache-domains
				synced 2025-11-04 13:58:51 +01:00 
			
		
		
		
	Merge pull request #160 from nightah/fix-generation-scripts-newlines
Handle newlines in generation scripts
This commit is contained in:
		
						commit
						e843326fce
					
				@ -64,8 +64,8 @@ while read -r entry; do
 | 
				
			|||||||
                        done <<< $(cat ${basedir}/$filename | sort);
 | 
					                        done <<< $(cat ${basedir}/$filename | sort);
 | 
				
			||||||
                        # All other entries
 | 
					                        # All other entries
 | 
				
			||||||
                        while read -r fileentry; do
 | 
					                        while read -r fileentry; do
 | 
				
			||||||
                                # Ignore comments and wildcards
 | 
					                                # Ignore comments, newlines and wildcards
 | 
				
			||||||
                                if [[ $fileentry =~ ^(\#|\*\.) ]]; then
 | 
					                                if [[ $fileentry =~ ^(\#|\*\.) ]] || [[ -z $fileentry ]]; then
 | 
				
			||||||
                                        continue
 | 
					                                        continue
 | 
				
			||||||
                                fi
 | 
					                                fi
 | 
				
			||||||
                                parsed=$(echo $fileentry)
 | 
					                                parsed=$(echo $fileentry)
 | 
				
			||||||
 | 
				
			|||||||
@ -45,16 +45,18 @@ while read entry; do
 | 
				
			|||||||
			destfilename=$(echo $filename | sed -e 's/txt/conf/')
 | 
								destfilename=$(echo $filename | sed -e 's/txt/conf/')
 | 
				
			||||||
			outputfile=${outputdir}/${destfilename}
 | 
								outputfile=${outputdir}/${destfilename}
 | 
				
			||||||
			touch $outputfile
 | 
								touch $outputfile
 | 
				
			||||||
			echo "server:" >> $outputfile
 | 
					 | 
				
			||||||
			while read fileentry; do
 | 
								while read fileentry; do
 | 
				
			||||||
				# Ignore comments
 | 
									# Ignore comments and newlines
 | 
				
			||||||
				if [[ $fileentry == \#* ]]; then
 | 
									if [[ $fileentry == \#* ]] || [[ -z $fileentry ]]; then
 | 
				
			||||||
					continue
 | 
										continue
 | 
				
			||||||
				fi
 | 
									fi
 | 
				
			||||||
				parsed=$(echo $fileentry | sed -e "s/^\*\.//")
 | 
									parsed=$(echo $fileentry | sed -e "s/^\*\.//")
 | 
				
			||||||
				if grep -qx "$parsed" $outputfile; then
 | 
									if grep -qx "$parsed" $outputfile; then
 | 
				
			||||||
					continue
 | 
										continue
 | 
				
			||||||
				fi
 | 
									fi
 | 
				
			||||||
 | 
					        if [[ $(head -n 1 $outputfile) != "server:" ]]; then
 | 
				
			||||||
 | 
					            echo "server:" >> $outputfile
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
				echo "  local-zone: \"${parsed}\" redirect" >> $outputfile
 | 
									echo "  local-zone: \"${parsed}\" redirect" >> $outputfile
 | 
				
			||||||
				for i in ${cacheip}; do
 | 
									for i in ${cacheip}; do
 | 
				
			||||||
					echo "  local-data: \"${parsed} 30 IN A ${i}\"" >> $outputfile
 | 
										echo "  local-data: \"${parsed} 30 IN A ${i}\"" >> $outputfile
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user