Change dummy domain and show device's hostname in ping

* Change dummy domain
Allows users to access Pi-hole console with my.pi-hole.net instead of the IP address

* Cleaned up formatting

* Put device hostname at the top of the list
Changed my.pi-hole.net to pi.hole and placed it under the device hostname. This way, ping will return the device hostname but you still can access the web interface with pi.hole/admin
pull/419/head
Mcat12 8 years ago
parent ae2117ff5a
commit 0fbf72bb09

@ -50,9 +50,6 @@ if [[ -f $piholeIPv6file ]];then
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
fi
# Variables for various stages of downloading and formatting the list
## Nate 3/26/2016 - Commented unused variables
basename=pihole
@ -74,9 +71,7 @@ if [[ -r $piholeDir/pihole.conf ]];then
. $piholeDir/pihole.conf
fi
spinner()
{
spinner() {
local pid=$1
local delay=0.50
local spinstr='|/-\'
@ -225,10 +220,8 @@ function gravity_Schwarzchild() {
cat "$i" | tr -d '\r' >> $piholeDir/$matterandlight
done
echo " done!"
}
function gravity_Blacklist(){
# Append blacklist entries if they exist
echo -n "::: Running blacklist script to update HOSTS file...."
@ -237,11 +230,8 @@ function gravity_Blacklist(){
numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt")
plural=; [[ "$numBlacklisted" != "1" ]] && plural=s
echo " $numBlacklisted domain${plural} blacklisted!"
}
function gravity_Whitelist() {
echo ":::"
# Prevent our sources from being pulled into the hole
@ -261,9 +251,6 @@ function gravity_Whitelist() {
numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt")
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
echo " $numWhitelisted domain${plural} whitelisted!"
}
function gravity_unique() {
@ -278,17 +265,19 @@ function gravity_unique() {
function gravity_hostFormat() {
# Format domain list as "192.168.x.x domain.com"
echo "::: Formatting domains into a HOSTS file..."
hostname=$(</etc/hostname)
# 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 $piholeIPv6 ]];then
#Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain!
echo -e "$piholeIP Pi-Hole.IsWorking.OK \n$piholeIPv6 Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc
# 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$piholeIPv6 $hostname\n$piholeIP pi.hole\n$piholeIPv6 pi.hole" > $piholeDir/$accretionDisc
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc
else
# Otherwise, just create gravity.list as normal using IPv4
#Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain!
echo -e "$piholeIP Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc
# 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
fi
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
cp $piholeDir/$accretionDisc $adList
}
@ -308,8 +297,6 @@ function gravity_blackbody() {
}
function gravity_advanced() {
# Remove comments and print only the domain name
# Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious
# This helps with that and makes it easier to read
@ -322,7 +309,6 @@ function gravity_advanced() {
echo "::: $numberOf domains being pulled in by gravity..."
gravity_unique
}
function gravity_reload() {

Loading…
Cancel
Save