mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-02-26 21:18:18 +00:00
change writehost to PromoFaux proposed
This commit is contained in:
parent
35df1844cb
commit
f14c802822
1 changed files with 25 additions and 20 deletions
45
gravity.sh
45
gravity.sh
|
@ -204,26 +204,31 @@ gravity_unique() {
|
||||||
}
|
}
|
||||||
|
|
||||||
gravity_hostFormat() {
|
gravity_hostFormat() {
|
||||||
# Format domain list as "192.168.x.x domain.com"
|
# Format domain list as "192.168.x.x domain.com"
|
||||||
echo "::: Formatting domains into a HOSTS file..."
|
echo "::: Formatting domains into a HOSTS file..."
|
||||||
if [[ -f /etc/hostname ]]; then
|
if [[ -f /etc/hostname ]]; then
|
||||||
hostname=$(</etc/hostname)
|
hostname=$(</etc/hostname)
|
||||||
elif [ -x "$(command -v hostname)" ]; then
|
elif [ -x "$(command -v hostname)" ]; then
|
||||||
hostname=$(hostname -f)
|
hostname=$(hostname -f)
|
||||||
else
|
else
|
||||||
echo "::: Error: Unable to determine fully qualified domain name of host"
|
echo "::: Error: Unable to determine fully qualified domain name of host"
|
||||||
fi
|
fi
|
||||||
# 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)
|
|
||||||
if [[ -n "${IPv6_address}" ]] ; then
|
# Check vars from setupVars.conf to see if we're using IPv4, IPv6, Or both.
|
||||||
echo -e "${IPv6_address} $hostname\n${IPv6_address} pi.hole" >> ${piholeDir}/${accretionDisc}
|
if [[ -n "${IPv4_address}" && -n "${IPv6_address}" ]];then
|
||||||
cat ${piholeDir}/${eventHorizon} | awk -v ipv6addr="${IPv6_address}" '{sub(/\r$/,""); print ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
# Both IPv4 and IPv6
|
||||||
fi
|
echo -e "$IPv4_address $hostname\n$IPv6_address $hostname\n$IPv4_address pi.hole\n$IPv6_address pi.hole" > ${piholeDir}/${accretionDisc}
|
||||||
if [[ -n "${IPv4_address}" ]] ; then
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4_address" -v ipv6addr="$IPv6_address" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${piholeDir}/${accretionDi$
|
||||||
echo -e "${IPv4_address} $hostname\n${IPv4_address} pi.hole" >> ${piholeDir}/${accretionDisc}
|
elif [[ -n "${IPv4_address}" && -z "${IPv6_address}" ]];then
|
||||||
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="${IPv4_address}" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
# Only IPv4
|
||||||
fi
|
echo -e "$IPv4addr $hostname\n$IPv4addr pi.hole" > ${piholeDir}/${accretionDisc}
|
||||||
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4_address" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||||
cp ${piholeDir}/${accretionDisc} ${adList}
|
elif [[ -z "${IPv4_address}" && -n "${IPv6_address}" ]];then
|
||||||
|
# Only IPv6
|
||||||
|
echo -e "$IPv6_address $hostname\n$IPv6_address pi.hole" > ${piholeDir}/${accretionDisc}
|
||||||
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv6addr="$IPv6_address" '{sub(/\r$/,""); print ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||||
|
fi # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
||||||
|
cp ${piholeDir}/${accretionDisc} ${adList}
|
||||||
}
|
}
|
||||||
|
|
||||||
# blackbody - remove any remnant files from script processes
|
# blackbody - remove any remnant files from script processes
|
||||||
|
|
Loading…
Add table
Reference in a new issue