Prevent redundant entries in to adlists.list
Grep ${args[3]} and only add if grep -c -eq 0 Signed-off-by: Ryan Knapper <ryanknapper@gmail.com>
This commit is contained in:
parent
607664c860
commit
36945a67d0
|
@ -182,10 +182,6 @@ trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC68345710423
|
||||||
|
|
||||||
add_dnsmasq_setting "interface" "${PIHOLE_INTERFACE}"
|
add_dnsmasq_setting "interface" "${PIHOLE_INTERFACE}"
|
||||||
fi
|
fi
|
||||||
if [[ "${CONDITIONAL_FORWARDING}" == true ]]; then
|
|
||||||
add_dnsmasq_setting "server=/${CONDITIONAL_FORWARDING_DOMAIN}/${CONDITIONAL_FORWARDING_IP}"
|
|
||||||
add_dnsmasq_setting "server=/${CONDITIONAL_FORWARDING_REVERSE}/${CONDITIONAL_FORWARDING_IP}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,17 +211,6 @@ SetDNSServers() {
|
||||||
else
|
else
|
||||||
change_setting "DNSSEC" "false"
|
change_setting "DNSSEC" "false"
|
||||||
fi
|
fi
|
||||||
if [[ "${args[6]}" == "conditional_forwarding" ]]; then
|
|
||||||
change_setting "CONDITIONAL_FORWARDING" "true"
|
|
||||||
change_setting "CONDITIONAL_FORWARDING_IP" "${args[7]}"
|
|
||||||
change_setting "CONDITIONAL_FORWARDING_DOMAIN" "${args[8]}"
|
|
||||||
change_setting "CONDITIONAL_FORWARDING_REVERSE" "${args[9]}"
|
|
||||||
else
|
|
||||||
change_setting "CONDITIONAL_FORWARDING" "false"
|
|
||||||
delete_setting "CONDITIONAL_FORWARDING_IP"
|
|
||||||
delete_setting "CONDITIONAL_FORWARDING_DOMAIN"
|
|
||||||
delete_setting "CONDITIONAL_FORWARDING_REVERSE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ProcessDNSSettings
|
ProcessDNSSettings
|
||||||
|
|
||||||
|
@ -269,7 +254,7 @@ ProcessDHCPSettings() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${PIHOLE_DOMAIN}" == "" ]]; then
|
if [[ "${PIHOLE_DOMAIN}" == "" ]]; then
|
||||||
PIHOLE_DOMAIN="local"
|
PIHOLE_DOMAIN="lan"
|
||||||
change_setting "PIHOLE_DOMAIN" "${PIHOLE_DOMAIN}"
|
change_setting "PIHOLE_DOMAIN" "${PIHOLE_DOMAIN}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -361,7 +346,9 @@ CustomizeAdLists() {
|
||||||
elif [[ "${args[2]}" == "disable" ]]; then
|
elif [[ "${args[2]}" == "disable" ]]; then
|
||||||
sed -i "\\@${args[3]}@s/^http/#http/g" "${list}"
|
sed -i "\\@${args[3]}@s/^http/#http/g" "${list}"
|
||||||
elif [[ "${args[2]}" == "add" ]]; then
|
elif [[ "${args[2]}" == "add" ]]; then
|
||||||
echo "${args[3]}" >> ${list}
|
if [[ $(grep -c "${args[3]}" "${list}") -eq 0 ]] ; then
|
||||||
|
echo "${args[3]}" >> ${list}
|
||||||
|
fi
|
||||||
elif [[ "${args[2]}" == "del" ]]; then
|
elif [[ "${args[2]}" == "del" ]]; then
|
||||||
var=$(echo "${args[3]}" | sed 's/\//\\\//g')
|
var=$(echo "${args[3]}" | sed 's/\//\\\//g')
|
||||||
sed -i "/${var}/Id" "${list}"
|
sed -i "/${var}/Id" "${list}"
|
||||||
|
|
Loading…
Reference in New Issue