mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-02-26 21:18:18 +00:00
make hosts with ivp4 and 6
This commit is contained in:
parent
e93f8d59d9
commit
67f553a7f2
3 changed files with 20 additions and 13 deletions
|
@ -96,7 +96,12 @@ ModifyHostFile(){
|
|||
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
||||
echo ":::"
|
||||
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
|
||||
sed "s/^/$piholeIP /g" ${blacklist} >> ${adList}
|
||||
if [[ -n "${IPv6_address}" ]] ; then
|
||||
sed "s/^/${IPv6_address} /g" ${blacklist} >> ${adList}
|
||||
fi
|
||||
if [[ -n "${IPv4_address}" ]] ; then
|
||||
sed "s/^/${IPv4_address} /g" ${blacklist} >> ${adList}
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo ":::"
|
||||
|
|
|
@ -102,7 +102,12 @@ ModifyHostFile(){
|
|||
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
||||
echo ":::"
|
||||
echo -n "::: Modifying HOSTS file to whitelist $numberOf domain${plural}..."
|
||||
awk -F':' '{print $1}' ${whitelist} | while read -r line; do echo "$piholeIP $line"; done > ${piholeDir}/whitelist.tmp
|
||||
if [[ -n "${IPv6_address}" ]] ; then
|
||||
awk -F':' '{print $1}' ${whitelist} | while read -r line; do echo "${IPv6_address} $line"; done >> ${piholeDir}/whitelist.tmp
|
||||
fi
|
||||
if [[ -n "${IPv4_address}" ]] ; then
|
||||
awk -F':' '{print $1}' ${whitelist} | while read -r line; do echo "${IPv4_address} $line"; done >> ${piholeDir}/whitelist.tmp
|
||||
fi
|
||||
echo "l" >> ${piholeDir}/whitelist.tmp
|
||||
grep -F -x -v -f ${piholeDir}/whitelist.tmp ${adList} > ${piholeDir}/gravity.tmp
|
||||
rm ${adList}
|
||||
|
|
19
gravity.sh
19
gravity.sh
|
@ -214,9 +214,14 @@ gravity_hostFormat() {
|
|||
echo "::: Error: Unable to determine fully qualified domain name of host"
|
||||
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)
|
||||
echo -e "$piholeIP $hostname\n$piholeIP pi.hole" > ${piholeDir}/${accretionDisc}
|
||||
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||
|
||||
if [[ -n "${IPv6_address}" ]] ; then
|
||||
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
|
||||
if [[ -n "${IPv4_address}" ]] ; then
|
||||
echo -e "${IPv4_address} $hostname\n${IPv4_address} pi.hole" > ${piholeDir}/${accretionDisc}
|
||||
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="${IPv4_address}" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||
fi
|
||||
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
||||
cp ${piholeDir}/${accretionDisc} ${adList}
|
||||
}
|
||||
|
@ -313,14 +318,6 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n "${IPv6_address}" ]] ; then
|
||||
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)
|
||||
if [[ -r ${piholeDir}/pihole.conf ]];then
|
||||
echo "::: pihole.conf file no longer supported. Over-rides in this file are ignored."
|
||||
|
|
Loading…
Add table
Reference in a new issue