From 2624e56de55fc860f47c82359d45e4d62f38d70d Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 6 Sep 2017 16:54:41 +0200 Subject: [PATCH 1/2] Parse /etc/openvpn/ipp.txt (if existing) and add entries to local.list. Signed-off-by: DL6ER --- gravity.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index 168a4350..78b7ebb6 100755 --- a/gravity.sh +++ b/gravity.sh @@ -53,6 +53,7 @@ piholeDir=/etc/${basename} adList=${piholeDir}/gravity.list blackList=${piholeDir}/black.list localList=${piholeDir}/local.list +VPNList=/etc/openvpn/ipp.txt justDomainsExtension=domains matterAndLight=${basename}.0.matterandlight.txt supernova=${basename}.1.supernova.txt @@ -217,7 +218,7 @@ gravity_Schwarzchild() { # Find all active domains and compile them into one file and remove CRs local str="Aggregating list of domains" echo -ne " ${INFO} ${str}..." - + truncate -s 0 ${piholeDir}/${matterAndLight} for i in "${activeDomains[@]}"; do # Only assimilate list if it is available (download might have failed permanently) @@ -337,6 +338,11 @@ gravity_hostFormatLocal() { rm "${localList}" gravity_doHostFormat "${localList}.tmp" "${localList}" rm "${localList}.tmp" + + # Generate local HOSTS list with information obtained from OpenVPN (if available) + if [[ -f ${VPNList} ]]; then + awk -F, '{for (i=NF; i>=1; i-=2) printf $i"\t"$(i-1) "\n" }' "${VPNList}" >> "${localList}" + fi } gravity_hostFormatGravity() { @@ -468,7 +474,7 @@ if [[ ! "${blackListOnly}" == true ]]; then echo -ne " ${INFO} ${str}..." rm ${piholeDir}/pihole.*.txt 2> /dev/null - + echo -e "${OVER} ${TICK} ${str}" fi From 4a90dac68e971b02ce3394bfc85fcd0933bd7d05 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 7 Sep 2017 19:42:00 +0200 Subject: [PATCH 2/2] Simplify awk code as the format of ipp.txt is actually fixed (only one entry per line is allowed) Signed-off-by: DL6ER --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 78b7ebb6..5519d11a 100755 --- a/gravity.sh +++ b/gravity.sh @@ -341,7 +341,7 @@ gravity_hostFormatLocal() { # Generate local HOSTS list with information obtained from OpenVPN (if available) if [[ -f ${VPNList} ]]; then - awk -F, '{for (i=NF; i>=1; i-=2) printf $i"\t"$(i-1) "\n" }' "${VPNList}" >> "${localList}" + awk -F, '{printf $2"\t"$1"\n"}' "${VPNList}" >> "${localList}" fi }