Merge pull request #140 from nightah/dnsmasq-refactor
Refactor Dnsmasq script to support multiple cache ips
This commit is contained in:
commit
6487d71677
@ -27,6 +27,7 @@ done <<< $(jq -r '.cache_domains | to_entries[] | .key' config.json)
|
||||
|
||||
rm -rf ${outputdir}
|
||||
mkdir -p ${outputdir}
|
||||
touch ${outputdir}/lancache.conf
|
||||
while read -r entry; do
|
||||
unset cacheip
|
||||
unset cachename
|
||||
@ -42,8 +43,9 @@ while read -r entry; do
|
||||
cacheip=$(jq -r 'if type == "array" then .[] else . end' <<< ${!cacheipname} | xargs)
|
||||
while read -r fileid; do
|
||||
while read -r filename; do
|
||||
destfilename=$(echo $filename | sed -e 's/txt/conf/')
|
||||
destfilename=$(echo $filename | sed -e 's/txt/hosts/')
|
||||
outputfile=${outputdir}/${destfilename}
|
||||
echo "addn-hosts=/etc/dnsmasq.d/${destfilename}" >> ${outputdir}/lancache.conf
|
||||
touch "$outputfile"
|
||||
while read -r fileentry; do
|
||||
# Ignore comments
|
||||
@ -55,7 +57,7 @@ while read -r entry; do
|
||||
continue
|
||||
fi
|
||||
for i in ${cacheip}; do
|
||||
echo "address=/${parsed}/${i}" >> "$outputfile"
|
||||
echo "${i} ${parsed}" >> "$outputfile"
|
||||
done
|
||||
done <<< $(cat ${basedir}/$filename);
|
||||
done <<< $(jq -r ".cache_domains[$entry].domain_files[$fileid]" $path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user