mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-28 17:13:17 +00:00
Merge remote-tracking branch 'origin/development' into ExportVariables
This commit is contained in:
commit
6c24d5b633
15 changed files with 476 additions and 119 deletions
7
.github/ISSUE_TEMPLATE.md
vendored
Normal file
7
.github/ISSUE_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
##### Expected Behaviour:
|
||||||
|
|
||||||
|
|
||||||
|
##### Actual Behaviour:
|
||||||
|
|
||||||
|
|
||||||
|
##### Steps to reproduce this issue:
|
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Fixes #[issue number] .
|
||||||
|
|
||||||
|
Changes proposed in this pull request:
|
||||||
|
|
||||||
|
-
|
||||||
|
|
||||||
|
-
|
||||||
|
|
||||||
|
-
|
||||||
|
|
||||||
|
@pihole/gravity
|
12
README.md
12
README.md
|
@ -1,11 +1,18 @@
|
||||||
# Automated Install
|
# Automated Install
|
||||||
##### Designed For Raspberry Pi B, B+, 2, and Zero (with an Ethernet adapter)
|
##### Designed For Raspberry Pi A+, B, B+, 2, Zero (with an Ethernet adapter), and also works on most Debian based distros!
|
||||||
|
|
||||||
1. Install Raspbian
|
1. Install Raspbian on Raspberry Pi variants or a Debian based distribution on other hardware or virtual machines
|
||||||
2. Run the command below
|
2. Run the command below
|
||||||
|
|
||||||
### ```curl -L install.pi-hole.net | bash```
|
### ```curl -L install.pi-hole.net | bash```
|
||||||
|
|
||||||
|
#### Alternative Semi-Automated install ####
|
||||||
|
```
|
||||||
|
wget -O basic-install.sh install.pi-hole.net
|
||||||
|
chmod +x basic-install.sh
|
||||||
|
./basic-install.sh
|
||||||
|
```
|
||||||
|
|
||||||
Once installed, [configure your router to have **DHCP clients use the Pi as their DNS server**](http://pi-hole.net/faq/can-i-set-the-pi-hole-to-be-the-dns-server-at-my-router-so-i-dont-have-to-change-settings-for-my-devices/) and then any device that connects to your network will have ads blocked without any further configuration. Alternatively, you can manually set each device to [use the Raspberry Pi as its DNS server](http://pi-hole.net/faq/how-do-i-use-the-pi-hole-as-my-dns-server/).
|
Once installed, [configure your router to have **DHCP clients use the Pi as their DNS server**](http://pi-hole.net/faq/can-i-set-the-pi-hole-to-be-the-dns-server-at-my-router-so-i-dont-have-to-change-settings-for-my-devices/) and then any device that connects to your network will have ads blocked without any further configuration. Alternatively, you can manually set each device to [use the Raspberry Pi as its DNS server](http://pi-hole.net/faq/how-do-i-use-the-pi-hole-as-my-dns-server/).
|
||||||
|
|
||||||
## Pi-hole Is Free, But Powered By Your Donations
|
## Pi-hole Is Free, But Powered By Your Donations
|
||||||
|
@ -17,6 +24,7 @@ Once installed, [configure your router to have **DHCP clients use the Pi as thei
|
||||||
[![Pi-hole exlplained](http://i.imgur.com/qNybJDX.png)](https://vimeo.com/135965232)
|
[![Pi-hole exlplained](http://i.imgur.com/qNybJDX.png)](https://vimeo.com/135965232)
|
||||||
|
|
||||||
## Pi-hole Projects
|
## Pi-hole Projects
|
||||||
|
- [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/)
|
||||||
- [Pi-hole Chrome extension](https://chrome.google.com/webstore/detail/pi-hole-list-editor/hlnoeoejkllgkjbnnnhfolapllcnaglh) ([open source](https://github.com/packtloss/pihole-extension))
|
- [Pi-hole Chrome extension](https://chrome.google.com/webstore/detail/pi-hole-list-editor/hlnoeoejkllgkjbnnnhfolapllcnaglh) ([open source](https://github.com/packtloss/pihole-extension))
|
||||||
- [Go Bananas for CHiP-hole ad blocking](https://www.hackster.io/jacobsalmela/chip-hole-network-wide-ad-blocker-98e037)
|
- [Go Bananas for CHiP-hole ad blocking](https://www.hackster.io/jacobsalmela/chip-hole-network-wide-ad-blocker-98e037)
|
||||||
- [Sky-Hole](http://dlaa.me/blog/post/skyhole)
|
- [Sky-Hole](http://dlaa.me/blog/post/skyhole)
|
||||||
|
|
|
@ -1,8 +1,49 @@
|
||||||
https://adaway.org/hosts.txt
|
## Pi-hole ad-list default sources. Updated 21/02/2016 #########################
|
||||||
|
# #
|
||||||
|
# To make changes to this file: #
|
||||||
|
# 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list` #
|
||||||
|
# 2. run `nano /etc/pihole/adlists.list` #
|
||||||
|
# 3. Uncomment or comment any of the below lists #
|
||||||
|
# #
|
||||||
|
# Know of any other lists? Feel free to let us know about them, or add them #
|
||||||
|
# to this file! #
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# The below list amalgamates several lists we used previously.
|
||||||
|
# See `https://github.com/StevenBlack/hosts` for details
|
||||||
|
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
|
||||||
|
|
||||||
|
# Other lists we consider safe:
|
||||||
http://adblock.gjtech.net/?format=unix-hosts
|
http://adblock.gjtech.net/?format=unix-hosts
|
||||||
http://hosts-file.net/ad_servers.txt
|
|
||||||
http://www.malwaredomainlist.com/hostslist/hosts.txt
|
|
||||||
http://pgl.yoyo.org/adservers/serverlist.php?
|
|
||||||
http://someonewhocares.org/hosts/hosts
|
|
||||||
http://winhelp2002.mvps.org/hosts.txt
|
|
||||||
http://mirror1.malwaredomains.com/files/justdomains
|
http://mirror1.malwaredomains.com/files/justdomains
|
||||||
|
http://sysctl.org/cameleon/hosts
|
||||||
|
https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist
|
||||||
|
https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt
|
||||||
|
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
|
||||||
|
|
||||||
|
# hosts-file.net list. Updated frequently, but has been known to block legitimate sites.
|
||||||
|
http://hosts-file.net/ad_servers.txt
|
||||||
|
|
||||||
|
# Mahakala list. Has been known to block legitimage domains including the entire .com range.
|
||||||
|
#http://adblock.mahakala.is/
|
||||||
|
|
||||||
|
# ADZHOSTS list. Has been known to block legitimate domains
|
||||||
|
#http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt
|
||||||
|
|
||||||
|
# Windows 10 telemetry list
|
||||||
|
#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/hostsBlockWindowsSpy.txt
|
||||||
|
|
||||||
|
# Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc)
|
||||||
|
#http://securemecca.com/Downloads/hosts.txt
|
||||||
|
|
||||||
|
# Quidsup's tracker list
|
||||||
|
https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt
|
||||||
|
|
||||||
|
# Block the BBC News website Breaking News banner
|
||||||
|
#https://raw.githubusercontent.com/BreakingTheNews/BreakingTheNews.github.io/master/hosts
|
||||||
|
|
||||||
|
|
||||||
|
# Untested Lists:
|
||||||
|
#https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt
|
||||||
|
#http://spam404bl.com/spam404scamlist.txt
|
||||||
|
#http://malwaredomains.lehigh.edu/files/domains.txt
|
||||||
|
|
|
@ -51,9 +51,13 @@ function CalcblockedToday(){
|
||||||
|
|
||||||
function CalcPercentBlockedToday(){
|
function CalcPercentBlockedToday(){
|
||||||
if [ "$queriesToday" != "Err." ] && [ "$blockedToday" != "Err." ]; then
|
if [ "$queriesToday" != "Err." ] && [ "$blockedToday" != "Err." ]; then
|
||||||
#scale 2 rounds the number down, so we'll do scale 4 and then trim the last 2 zeros
|
if [ "$queriesToday" != 0 ]; then #Fixes divide by zero error :)
|
||||||
percentBlockedToday=$(echo "scale=4; $blockedToday/$queriesToday*100" | bc)
|
#scale 2 rounds the number down, so we'll do scale 4 and then trim the last 2 zeros
|
||||||
percentBlockedToday=$(sed 's/.\{2\}$//' <<< "$percentBlockedToday")
|
percentBlockedToday=$(echo "scale=4; $blockedToday/$queriesToday*100" | bc)
|
||||||
|
percentBlockedToday=$(sed 's/.\{2\}$//' <<< "$percentBlockedToday")
|
||||||
|
else
|
||||||
|
percentBlockedToday=0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +88,8 @@ function normalChrono(){
|
||||||
echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
|
echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
|
||||||
echo ""
|
echo ""
|
||||||
uptime | cut -d' ' -f11-
|
uptime | cut -d' ' -f11-
|
||||||
|
#uptime -p #Doesn't work on all versions of uptime
|
||||||
|
uptime | awk -F'( |,|:)+' '{if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes."}'
|
||||||
echo "-------------------------------"
|
echo "-------------------------------"
|
||||||
# Uncomment to continually read the log file and display the current domain being blocked
|
# Uncomment to continually read the log file and display the current domain being blocked
|
||||||
#tail -f /var/log/pihole.log | awk '/\/etc\/pihole\/gravity.list/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/pihole/gravity.list") print $7; else;}'
|
#tail -f /var/log/pihole.log | awk '/\/etc\/pihole\/gravity.list/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/pihole/gravity.list") print $7; else;}'
|
||||||
|
|
89
advanced/Scripts/setupLCD.sh
Normal file
89
advanced/Scripts/setupLCD.sh
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Pi-hole: A black hole for Internet advertisements
|
||||||
|
# (c) 2015 by Jacob Salmela
|
||||||
|
# Network-wide ad blocking via your Raspberry Pi
|
||||||
|
# http://pi-hole.net
|
||||||
|
# Automatically configures the Pi to use the 2.8 LCD screen to display stats on it (also works over ssh)
|
||||||
|
#
|
||||||
|
# Pi-hole is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
############ FUNCTIONS ###########
|
||||||
|
# Run this script as root or under sudo
|
||||||
|
echo ":::"
|
||||||
|
if [[ $EUID -eq 0 ]];then
|
||||||
|
echo "::: You are root."
|
||||||
|
else
|
||||||
|
echo "::: sudo will be used."
|
||||||
|
# Check if it is actually installed
|
||||||
|
# If it isn't, exit because the install cannot complete
|
||||||
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
|
export SUDO="sudo"
|
||||||
|
else
|
||||||
|
echo "::: Please install sudo or run this script as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Borrowed from adafruit-pitft-helper < borrowed from raspi-config
|
||||||
|
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L324-L334
|
||||||
|
getInitSys() {
|
||||||
|
if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then
|
||||||
|
SYSTEMD=1
|
||||||
|
elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then
|
||||||
|
SYSTEMD=0
|
||||||
|
else
|
||||||
|
echo "Unrecognised init system"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Borrowed from adafruit-pitft-helper:
|
||||||
|
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L274-L285
|
||||||
|
autoLoginPiToConsole() {
|
||||||
|
if [ -e /etc/init.d/lightdm ]; then
|
||||||
|
if [ $SYSTEMD -eq 1 ]; then
|
||||||
|
$SUDO systemctl set-default multi-user.target
|
||||||
|
$SUDO ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
|
||||||
|
else
|
||||||
|
$SUDO update-rc.d lightdm disable 2
|
||||||
|
$SUDO sed /etc/inittab -i -e "s/1:2345:respawn:\/sbin\/getty --noclear 38400 tty1/1:2345:respawn:\/bin\/login -f pi tty1 <\/dev\/tty1 >\/dev\/tty1 2>&1/"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
######### SCRIPT ###########
|
||||||
|
# Set pi to log in automatically
|
||||||
|
getInitSys
|
||||||
|
autoLoginPiToConsole
|
||||||
|
|
||||||
|
# Set chronomter to run automatically when pi logs in
|
||||||
|
echo /usr/local/bin/chronometer.sh >> /home/pi/.bashrc
|
||||||
|
# OR
|
||||||
|
#$SUDO echo /usr/local/bin/chronometer.sh >> /etc/profile
|
||||||
|
|
||||||
|
# Set up the LCD screen based on Adafruits instuctions:
|
||||||
|
# https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/easy-install
|
||||||
|
curl -SLs https://apt.adafruit.com/add-pin | $SUDO bash
|
||||||
|
$SUDO apt-get -y install raspberrypi-bootloader
|
||||||
|
$SUDO apt-get -y install adafruit-pitft-helper
|
||||||
|
$SUDO adafruit-pitft-helper -t 28r
|
||||||
|
|
||||||
|
# Download the cmdline.txt file that prevents the screen from going blank after a period of time
|
||||||
|
$SUDO mv /boot/cmdline.txt /boot/cmdline.orig
|
||||||
|
$SUDO curl -o /boot/cmdline.txt https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/cmdline.txt
|
||||||
|
|
||||||
|
# Back up the original file and download the new one
|
||||||
|
$SUDO mv /etc/default/console-setup /etc/default/console-setup.orig
|
||||||
|
$SUDO curl -o /etc/default/console-setup https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/console-setup
|
||||||
|
|
||||||
|
# Instantly apply the font change to the LCD screen
|
||||||
|
$SUDO setupcon
|
||||||
|
|
||||||
|
$SUDO reboot
|
||||||
|
|
||||||
|
# Start showing the stats on the screen by running the command on another tty:
|
||||||
|
# http://unix.stackexchange.com/questions/170063/start-a-process-on-a-different-tty
|
||||||
|
#setsid sh -c 'exec /usr/local/bin/chronometer.sh <> /dev/tty1 >&0 2>&1'
|
1
advanced/cmdline.txt
Normal file
1
advanced/cmdline.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait fbcon=map:10 fbcon=font:VGA8x8 consoleblank=0
|
17
advanced/console-setup
Normal file
17
advanced/console-setup
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# CONFIGURATION FILE FOR SETUPCON
|
||||||
|
|
||||||
|
# Consult the console-setup(5) manual page.
|
||||||
|
|
||||||
|
ACTIVE_CONSOLES="/dev/tty[1-6]"
|
||||||
|
|
||||||
|
CHARMAP="UTF-8"
|
||||||
|
|
||||||
|
# For best results with the Adafruit 2.8 LCD and Pi-hole's chronometer
|
||||||
|
CODESET="guess"
|
||||||
|
FONTFACE="Terminus"
|
||||||
|
FONTSIZE="10x20"
|
||||||
|
|
||||||
|
VIDEOMODE=
|
||||||
|
|
||||||
|
# The following is an example how to use a braille font
|
||||||
|
# FONT='lat9w-08.psf.gz brl-8x8.psf'
|
|
@ -115,6 +115,25 @@ welcomeDialogs() {
|
||||||
In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c
|
In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
verifyFreeDiskSpace() {
|
||||||
|
# 25MB is the minimum space needed (20MB install + 5MB one day of logs.)
|
||||||
|
requiredFreeBytes=51200
|
||||||
|
|
||||||
|
existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1`
|
||||||
|
if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then
|
||||||
|
existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1`
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then
|
||||||
|
whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c
|
||||||
|
echo "$existingFreeBytes is less than $requiredFreeBytes"
|
||||||
|
echo "Insufficient free space, exiting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
chooseInterface() {
|
chooseInterface() {
|
||||||
# Turn the available interfaces into an array so it can be used with a whiptail dialog
|
# Turn the available interfaces into an array so it can be used with a whiptail dialog
|
||||||
interfacesArray=()
|
interfacesArray=()
|
||||||
|
@ -148,6 +167,12 @@ chooseInterface() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanupIPv6() {
|
||||||
|
# Removes IPv6 indicator file if we are not using IPv6
|
||||||
|
if [ -f "/etc/pihole/.useIPv6" ] && [ ! $useIPv6 ]; then
|
||||||
|
rm /etc/pihole/.useIPv6
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
use4andor6() {
|
use4andor6() {
|
||||||
# Let use select IPv4 and/or IPv6
|
# Let use select IPv4 and/or IPv6
|
||||||
|
@ -187,6 +212,7 @@ use4andor6() {
|
||||||
echo "::: Exiting"
|
echo "::: Exiting"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
cleanupIPv6
|
||||||
else
|
else
|
||||||
echo "::: Cancel selected. Exiting..."
|
echo "::: Cancel selected. Exiting..."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -278,10 +304,31 @@ setStaticIPv4() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function valid_ip()
|
||||||
|
{
|
||||||
|
local ip=$1
|
||||||
|
local stat=1
|
||||||
|
|
||||||
|
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||||
|
OIFS=$IFS
|
||||||
|
IFS='.'
|
||||||
|
ip=($ip)
|
||||||
|
IFS=$OIFS
|
||||||
|
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
|
||||||
|
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
|
||||||
|
stat=$?
|
||||||
|
fi
|
||||||
|
return $stat
|
||||||
|
}
|
||||||
|
|
||||||
setDNS(){
|
setDNS(){
|
||||||
DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 2)
|
DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." $r $c 6)
|
||||||
DNSChooseOptions=(Google "" on
|
DNSChooseOptions=(Google "" on
|
||||||
OpenDNS "" off)
|
OpenDNS "" off
|
||||||
|
Level3 "" off
|
||||||
|
Norton "" off
|
||||||
|
Comodo "" off
|
||||||
|
Custom "" off)
|
||||||
DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty)
|
DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty)
|
||||||
if [[ $? = 0 ]];then
|
if [[ $? = 0 ]];then
|
||||||
case $DNSchoices in
|
case $DNSchoices in
|
||||||
|
@ -295,6 +342,79 @@ setDNS(){
|
||||||
piholeDNS1="208.67.222.222"
|
piholeDNS1="208.67.222.222"
|
||||||
piholeDNS2="208.67.220.220"
|
piholeDNS2="208.67.220.220"
|
||||||
;;
|
;;
|
||||||
|
Level3)
|
||||||
|
echo "::: Using Level3 servers."
|
||||||
|
piholeDNS1="4.2.2.1"
|
||||||
|
piholeDNS2="4.2.2.2"
|
||||||
|
;;
|
||||||
|
Norton)
|
||||||
|
echo "::: Using Norton ConnectSafe servers."
|
||||||
|
piholeDNS1="199.85.126.10"
|
||||||
|
piholeDNS2="199.85.127.10"
|
||||||
|
;;
|
||||||
|
Comodo)
|
||||||
|
echo "::: Using Comodo Secure servers."
|
||||||
|
piholeDNS1="8.26.56.26"
|
||||||
|
piholeDNS2="8.20.247.20"
|
||||||
|
;;
|
||||||
|
Custom)
|
||||||
|
until [[ $DNSSettingsCorrect = True ]]
|
||||||
|
do
|
||||||
|
|
||||||
|
strInvalid="Invalid"
|
||||||
|
|
||||||
|
if [ ! $piholeDNS1 ]; then
|
||||||
|
if [ ! $piholeDNS2 ]; then
|
||||||
|
prePopulate=""
|
||||||
|
else
|
||||||
|
prePopulate=", $piholeDNS2"
|
||||||
|
fi
|
||||||
|
elif [ $piholeDNS1 ] && [ ! $piholeDNS2 ]; then
|
||||||
|
prePopulate="$piholeDNS1"
|
||||||
|
elif [ $piholeDNS1 ] && [ $piholeDNS2 ]; then
|
||||||
|
prePopulate="$piholeDNS1, $piholeDNS2"
|
||||||
|
fi
|
||||||
|
|
||||||
|
piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), seperated by a comma.\n\nFor example '8.8.8.8, 8.8.4.4'" $r $c "$prePopulate" 3>&1 1>&2 2>&3)
|
||||||
|
if [[ $? = 0 ]];then
|
||||||
|
piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}')
|
||||||
|
piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}')
|
||||||
|
|
||||||
|
if ! valid_ip $piholeDNS1 || [ ! $piholeDNS1 ]; then
|
||||||
|
piholeDNS1=$strInvalid
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! valid_ip $piholeDNS2 && [ $piholeDNS2 ]; then
|
||||||
|
piholeDNS2=$strInvalid
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "::: Cancel selected, exiting...."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $piholeDNS1 == $strInvalid ]] || [[ $piholeDNS2 == $strInvalid ]]; then
|
||||||
|
whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c
|
||||||
|
|
||||||
|
if [[ $piholeDNS1 == $strInvalid ]]; then
|
||||||
|
piholeDNS1=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $piholeDNS2 == $strInvalid ]]; then
|
||||||
|
piholeDNS2=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
DNSSettingsCorrect=False
|
||||||
|
else
|
||||||
|
if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then
|
||||||
|
DNSSettingsCorrect=True
|
||||||
|
else
|
||||||
|
# If the settings are wrong, the loop continues
|
||||||
|
DNSSettingsCorrect=False
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
echo "::: Cancel selected. Exiting..."
|
echo "::: Cancel selected. Exiting..."
|
||||||
|
@ -331,12 +451,20 @@ versionCheckDNSmasq(){
|
||||||
echo " done."
|
echo " done."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::: Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf..."
|
echo -n "::: Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf..."
|
||||||
$SUDO cp $newFileToInstall $newFileFinalLocation
|
$SUDO cp $newFileToInstall $newFileFinalLocation
|
||||||
echo " done."
|
echo " done."
|
||||||
$SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation
|
$SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation
|
||||||
$SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation
|
if [[ "$piholeDNS1" != "" ]]; then
|
||||||
$SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation
|
$SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation
|
||||||
|
else
|
||||||
|
$SUDO sed -i '/^server=@DNS1@/d' $newFileFinalLocation
|
||||||
|
fi
|
||||||
|
if [[ "$piholeDNS2" != "" ]]; then
|
||||||
|
$SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation
|
||||||
|
else
|
||||||
|
$SUDO sed -i '/^server=@DNS2@/d' $newFileFinalLocation
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
installScripts() {
|
installScripts() {
|
||||||
|
@ -366,7 +494,7 @@ stopServices() {
|
||||||
# Stop dnsmasq and lighttpd
|
# Stop dnsmasq and lighttpd
|
||||||
$SUDO echo ":::"
|
$SUDO echo ":::"
|
||||||
$SUDO echo -n "::: Stopping services..."
|
$SUDO echo -n "::: Stopping services..."
|
||||||
$SUDO service dnsmasq stop & spinner $! || true
|
#$SUDO service dnsmasq stop & spinner $! || true
|
||||||
$SUDO service lighttpd stop & spinner $! || true
|
$SUDO service lighttpd stop & spinner $! || true
|
||||||
$SUDO echo " done."
|
$SUDO echo " done."
|
||||||
}
|
}
|
||||||
|
@ -393,7 +521,7 @@ checkForDependencies() {
|
||||||
fi
|
fi
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Checking apt-get for upgraded packages...."
|
echo -n "::: Checking apt-get for upgraded packages...."
|
||||||
updatesToInstall=$(sudo apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst)
|
updatesToInstall=$($SUDO apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst)
|
||||||
echo " done!"
|
echo " done!"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
if [[ $updatesToInstall -eq "0" ]]; then
|
if [[ $updatesToInstall -eq "0" ]]; then
|
||||||
|
@ -519,21 +647,44 @@ runGravity() {
|
||||||
/usr/local/bin/gravity.sh
|
/usr/local/bin/gravity.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setUser(){
|
||||||
|
# Check if user pihole exists and create if not
|
||||||
|
echo "::: Checking if user 'pihole' exists..."
|
||||||
|
if id -u pihole > /dev/null 2>&1; then
|
||||||
|
echo "::: User 'pihole' already exists"
|
||||||
|
else
|
||||||
|
echo "::: User 'pihole' doesn't exist. Creating..."
|
||||||
|
$SUDO useradd -r -s /usr/sbin/nologin pihole
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
setPassword() {
|
||||||
|
# Password needed to authorize changes to lists from admin page
|
||||||
|
pass=$(whiptail --passwordbox "Please enter a password to secure your Pi-hole web interface." 10 50 3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
|
if [ $? = 0 ]; then
|
||||||
|
# Entered password
|
||||||
|
echo $pass > /etc/pihole/password.txt
|
||||||
|
else
|
||||||
|
echo "::: Cancel selected, exiting...."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
installPihole() {
|
installPihole() {
|
||||||
# Install base files and web interface
|
# Install base files and web interface
|
||||||
checkForDependencies # done
|
checkForDependencies # done
|
||||||
stopServices
|
stopServices
|
||||||
|
setUser
|
||||||
$SUDO mkdir -p /etc/pihole/
|
$SUDO mkdir -p /etc/pihole/
|
||||||
$SUDO chown www-data:www-data /var/www/html
|
$SUDO chown www-data:www-data /var/www/html
|
||||||
$SUDO chmod 775 /var/www/html
|
$SUDO chmod 775 /var/www/html
|
||||||
$SUDO usermod -a -G www-data pi
|
$SUDO usermod -a -G www-data pihole
|
||||||
$SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null
|
$SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null
|
||||||
|
|
||||||
getGitFiles
|
getGitFiles
|
||||||
installScripts
|
installScripts
|
||||||
installConfigs
|
installConfigs
|
||||||
#installWebAdmin
|
|
||||||
CreateLogFile
|
CreateLogFile
|
||||||
installPiholeWeb
|
installPiholeWeb
|
||||||
installCron
|
installCron
|
||||||
|
@ -557,6 +708,9 @@ The install log is in /etc/pihole." $r $c
|
||||||
$SUDO mkdir -p /etc/pihole/
|
$SUDO mkdir -p /etc/pihole/
|
||||||
welcomeDialogs
|
welcomeDialogs
|
||||||
|
|
||||||
|
# Verify there is enough disk space for the install
|
||||||
|
verifyFreeDiskSpace
|
||||||
|
|
||||||
# Just back up the original Pi-hole right away since it won't take long and it gets it out of the way
|
# Just back up the original Pi-hole right away since it won't take long and it gets it out of the way
|
||||||
backupLegacyPihole
|
backupLegacyPihole
|
||||||
# Find interfaces and let the user choose one
|
# Find interfaces and let the user choose one
|
||||||
|
@ -567,6 +721,9 @@ use4andor6
|
||||||
# Decide what upstream DNS Servers to use
|
# Decide what upstream DNS Servers to use
|
||||||
setDNS
|
setDNS
|
||||||
|
|
||||||
|
# Set the admin page password
|
||||||
|
setPassword
|
||||||
|
|
||||||
# Install and log everything to a file
|
# Install and log everything to a file
|
||||||
installPihole | tee $tmpLog
|
installPihole | tee $tmpLog
|
||||||
|
|
||||||
|
@ -577,7 +734,7 @@ displayFinalMessage
|
||||||
|
|
||||||
echo -n "::: Restarting services..."
|
echo -n "::: Restarting services..."
|
||||||
# Start services
|
# Start services
|
||||||
$SUDO service dnsmasq start
|
$SUDO service dnsmasq restart
|
||||||
$SUDO service lighttpd start
|
$SUDO service lighttpd start
|
||||||
echo " done."
|
echo " done."
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,6 @@ include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
|
||||||
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
|
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
|
||||||
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
|
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
|
||||||
|
|
||||||
$HTTP["host"] =~ "ads.hulu.com|ads-v-darwin.hulu.com" {
|
$HTTP["host"] =~ "ads.hulu.com|ads-v-darwin.hulu.com|ads-e-darwin.hulu.com" {
|
||||||
url.redirect = ( ".*" => "http://192.168.1.101:8200/MediaItems/19.mov")
|
url.redirect = ( ".*" => "http://192.168.1.101:8200/MediaItems/19.mov")
|
||||||
}
|
}
|
||||||
|
|
30
gravity.sh
30
gravity.sh
|
@ -31,6 +31,8 @@ piholeIPv6file=/etc/pihole/.useIPv6
|
||||||
|
|
||||||
adListFile=/etc/pihole/adlists.list
|
adListFile=/etc/pihole/adlists.list
|
||||||
adListDefault=/etc/pihole/adlists.default
|
adListDefault=/etc/pihole/adlists.default
|
||||||
|
whitelistScript=/usr/local/bin/whitelist.sh
|
||||||
|
blacklistScript=/usr/local/bin/blacklist.sh
|
||||||
|
|
||||||
if [[ -f $piholeIPfile ]];then
|
if [[ -f $piholeIPfile ]];then
|
||||||
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
||||||
|
@ -98,7 +100,12 @@ function gravity_collapse() {
|
||||||
echo -n "::: Custom adList file detected. Reading..."
|
echo -n "::: Custom adList file detected. Reading..."
|
||||||
sources=()
|
sources=()
|
||||||
while read -a line; do
|
while read -a line; do
|
||||||
sources+=($line)
|
#Do not read commented out or blank lines
|
||||||
|
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
||||||
|
echo "" > /dev/null
|
||||||
|
else
|
||||||
|
sources+=($line)
|
||||||
|
fi
|
||||||
done < $adListFile
|
done < $adListFile
|
||||||
echo " done!"
|
echo " done!"
|
||||||
else
|
else
|
||||||
|
@ -106,7 +113,12 @@ function gravity_collapse() {
|
||||||
echo -n "::: No custom adlist file detected, reading from default file..."
|
echo -n "::: No custom adlist file detected, reading from default file..."
|
||||||
sources=()
|
sources=()
|
||||||
while read -a line; do
|
while read -a line; do
|
||||||
sources+=($line)
|
#Do not read commented out or blank lines
|
||||||
|
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
||||||
|
echo "" > /dev/null
|
||||||
|
else
|
||||||
|
sources+=($line)
|
||||||
|
fi
|
||||||
done < $adListDefault
|
done < $adListDefault
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
|
@ -198,7 +210,7 @@ function gravity_spinup() {
|
||||||
# Default is a simple request
|
# Default is a simple request
|
||||||
*) cmd_ext=""
|
*) cmd_ext=""
|
||||||
esac
|
esac
|
||||||
gravity_transport $url $cmd_ext $agent
|
gravity_transport "$url" "$cmd_ext" "$agent"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +232,7 @@ function gravity_Schwarzchild() {
|
||||||
function gravity_Blacklist(){
|
function gravity_Blacklist(){
|
||||||
# Append blacklist entries if they exist
|
# Append blacklist entries if they exist
|
||||||
echo -n "::: Running blacklist script to update HOSTS file...."
|
echo -n "::: Running blacklist script to update HOSTS file...."
|
||||||
blacklist.sh -f -nr -q > /dev/null & spinner $!
|
$blacklistScript -f -nr -q > /dev/null & spinner $!
|
||||||
|
|
||||||
numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt")
|
numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt")
|
||||||
plural=; [[ "$numBlacklisted" != "1" ]] && plural=s
|
plural=; [[ "$numBlacklisted" != "1" ]] && plural=s
|
||||||
|
@ -245,7 +257,7 @@ function gravity_Whitelist() {
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
|
||||||
echo -n "::: Running whitelist script to update HOSTS file...."
|
echo -n "::: Running whitelist script to update HOSTS file...."
|
||||||
whitelist.sh -f -nr -q ${urls[@]} > /dev/null & spinner $!
|
$whitelistScript -f -nr -q ${urls[@]} > /dev/null & spinner $!
|
||||||
|
|
||||||
numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt")
|
numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt")
|
||||||
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
|
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
|
||||||
|
@ -316,11 +328,19 @@ function gravity_advanced() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_reload() {
|
function gravity_reload() {
|
||||||
|
#Clear no longer needed files...
|
||||||
|
echo ":::"
|
||||||
|
echo -n "::: Cleaning up un-needed files..."
|
||||||
|
$SUDO rm /etc/pihole/pihole.*
|
||||||
|
echo " done!"
|
||||||
|
|
||||||
# Reload hosts file
|
# Reload hosts file
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Refresh lists in dnsmasq..."
|
echo -n "::: Refresh lists in dnsmasq..."
|
||||||
dnsmasqPid=$(pidof dnsmasq)
|
dnsmasqPid=$(pidof dnsmasq)
|
||||||
|
|
||||||
|
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $!
|
||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
if [[ $dnsmasqPid ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
$SUDO kill -HUP $dnsmasqPid & spinner $!
|
$SUDO kill -HUP $dnsmasqPid & spinner $!
|
||||||
|
|
Loading…
Reference in a new issue