mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-26 17:20:15 +00:00
remove refrance to old ipv6_addr and test ipv4 and 6
This commit is contained in:
parent
189d19da37
commit
495568ea56
1 changed files with 182 additions and 188 deletions
24
gravity.sh
24
gravity.sh
|
@ -214,16 +214,10 @@ gravity_hostFormat() {
|
||||||
echo "::: Error: Unable to determine fully qualified domain name of host"
|
echo "::: Error: Unable to determine fully qualified domain name of host"
|
||||||
fi
|
fi
|
||||||
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
|
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
|
||||||
if [[ -n "${IPv6_address}" ]];then
|
|
||||||
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
|
||||||
echo -e "$IPv4addr $hostname\n$IPv6_address $hostname\n$IPv4addr pi.hole\n$IPv6_address pi.hole" > ${piholeDir}/${accretionDisc}
|
|
||||||
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4addr" -v ipv6addr="$IPv6_address" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
|
||||||
else
|
|
||||||
# Otherwise, just create gravity.list as normal using IPv4
|
# Otherwise, just create gravity.list as normal using IPv4
|
||||||
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
||||||
echo -e "$IPv4addr $hostname\n$IPv4addr pi.hole" > ${piholeDir}/${accretionDisc}
|
echo -e "$IPv4addr $hostname\n$IPv4addr pi.hole" > ${piholeDir}/${accretionDisc}
|
||||||
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4addr" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||||
fi
|
|
||||||
|
|
||||||
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
||||||
cp ${piholeDir}/${accretionDisc} ${adList}
|
cp ${piholeDir}/${accretionDisc} ${adList}
|
||||||
|
@ -277,7 +271,7 @@ gravity_reload() {
|
||||||
adList=${adList//\//\\\/}
|
adList=${adList//\//\\\/}
|
||||||
#Now replace the line in dnsmasq file
|
#Now replace the line in dnsmasq file
|
||||||
sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
|
sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
|
||||||
find "$piholeDir" -type f -exec chmod 666 {} \;
|
# find "$piholeDir" -type f -exec chmod 666 {} \;
|
||||||
|
|
||||||
dnsmasqPid=$(pidof dnsmasq)
|
dnsmasqPid=$(pidof dnsmasq)
|
||||||
|
|
||||||
|
@ -321,19 +315,19 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Remove the /* from the end of the IPv4addr.
|
if [[ -n "${IPv6_address}" ]] ; then
|
||||||
IPv4addr=${IPv4_address%/*}
|
piholeIP=${IPv6_address}
|
||||||
|
piholeIP=$(echo "${piholeIP}" | cut -f1 -d"/")
|
||||||
|
else
|
||||||
|
piholeIP=${IPv4_address}
|
||||||
|
piholeIP=$(echo "${piholeIP}" | cut -f1 -d"/")
|
||||||
|
fi
|
||||||
|
|
||||||
# Warn users still using pihole.conf that it no longer has any effect (I imagine about 2 people use it)
|
# Warn users still using pihole.conf that it no longer has any effect (I imagine about 2 people use it)
|
||||||
if [[ -r ${piholeDir}/pihole.conf ]];then
|
if [[ -r ${piholeDir}/pihole.conf ]];then
|
||||||
echo "::: pihole.conf file no longer supported. Over-rides in this file are ignored."
|
echo "::: pihole.conf file no longer supported. Over-rides in this file are ignored."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [[ ${forceGrav} == true ]]; then
|
if [[ ${forceGrav} == true ]]; then
|
||||||
echo -n "::: Deleting exising list cache..."
|
echo -n "::: Deleting exising list cache..."
|
||||||
for f in ${piholeDir}/list.* ; do
|
for f in ${piholeDir}/list.* ; do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue