mirror of
https://github.com/lancachenet/monolithic
synced 2025-02-16 12:58:26 +00:00
Fixed whitespace handling in domain lists
All whitespace removed from host entries before handling, blank lines are skipped This WILL mangle comments in the map files, but is best to ensure working files
This commit is contained in:
parent
12f9397291
commit
1cf7dc39fd
1 changed files with 11 additions and 1 deletions
|
@ -15,12 +15,22 @@ echo "map \$http_host \$cacheidentifier {" >> $OUTPUTFILE
|
|||
echo " hostnames;" >> $OUTPUTFILE
|
||||
echo " default \$http_host;" >> $OUTPUTFILE
|
||||
jq -r '.cache_domains | to_entries[] | .key' cache_domains.json | while read CACHE_ENTRY; do
|
||||
#for each cache entry, find the cache indentifier
|
||||
CACHE_IDENTIFIER=$(jq -r ".cache_domains[$CACHE_ENTRY].name" cache_domains.json)
|
||||
jq -r ".cache_domains[$CACHE_ENTRY].domain_files | to_entries[] | .key" cache_domains.json | while read CACHEHOSTS_FILEID; do
|
||||
#Get the key for each domain files
|
||||
jq -r ".cache_domains[$CACHE_ENTRY].domain_files[$CACHEHOSTS_FILEID]" cache_domains.json | while read CACHEHOSTS_FILENAME; do
|
||||
#Get the actual file name
|
||||
echo Reading cache ${CACHE_IDENTIFIER} from ${CACHEHOSTS_FILENAME}
|
||||
cat ${CACHEHOSTS_FILENAME} | while read CACHE_HOST; do
|
||||
echo " ${CACHE_HOST} ${CACHE_IDENTIFIER};" >> $OUTPUTFILE
|
||||
#for each file in the hosts file
|
||||
#remove all whitespace (mangles comments but ensures valid config files)
|
||||
echo "host: $CACHE_HOST"
|
||||
CACHE_HOST=${CACHE_HOST// /}
|
||||
echo "new host: $CACHE_HOST"
|
||||
if [ ! "x${CACHE_HOST}" == "x" ]; then
|
||||
echo " ${CACHE_HOST} ${CACHE_IDENTIFIER};" >> $OUTPUTFILE
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
|
|
Loading…
Add table
Reference in a new issue