Compare commits
84 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fe05ed13e5 | ||
|
3a46e7fc0a | ||
|
88674e21cf | ||
|
a0673c7028 | ||
|
592af80659 | ||
|
3ec9b3b021 | ||
|
ca2d3a192c | ||
|
209bf7d746 | ||
|
13777cc1aa | ||
|
bffc77e478 | ||
|
0ebb7eecdb | ||
|
99863bb799 | ||
|
800d2f0859 | ||
|
f397844603 | ||
|
2d895f328c | ||
|
b14b182084 | ||
|
8687d25d88 | ||
|
7001edcd1d | ||
|
4a1e88f4bf | ||
|
b41608d40b | ||
|
c5d45edf2d | ||
|
0116b6341c | ||
|
3e7ecda80f | ||
|
f0e5b2b6f9 | ||
|
5976ec9323 | ||
|
eb3463fad1 | ||
|
5f9e5869e9 | ||
|
950480bb77 | ||
|
6530ec58c7 | ||
|
b1515c5e3f | ||
|
6581f119fd | ||
|
9ad7c12710 | ||
|
8e289215b4 | ||
|
3718c3be56 | ||
|
c3c051385c | ||
|
21c688a8a8 | ||
|
668b883651 | ||
|
c396aeed52 | ||
|
40f541bc31 | ||
|
44974f98a0 | ||
|
b7cb3df9bc | ||
|
432e6d5395 | ||
|
fdf805bc7b | ||
|
73e13f3875 | ||
|
da959e1296 | ||
|
94600c54cb | ||
|
c4fc2e089d | ||
|
06444c1c27 | ||
|
f8897942f3 | ||
|
4d0b4cfb36 | ||
|
7116634739 | ||
|
36492f4857 | ||
|
3a887af513 | ||
|
3142992c57 | ||
|
68a9b88b58 | ||
|
3c801e5b91 | ||
|
ecd46f8560 | ||
|
dee8ce587d | ||
|
4c24186911 | ||
|
af360a1a20 | ||
|
b5406240c6 | ||
|
73bfbba5f7 | ||
|
46d7bfecdb | ||
|
a734927591 | ||
|
255706e173 | ||
|
b2fbf46e60 | ||
|
e37495d80b | ||
|
beb6b950f7 | ||
|
2d1c0be24e | ||
|
9941651b3c | ||
|
31fda124f3 | ||
|
b7f6498a5c | ||
|
282da1c2b6 | ||
|
8e6ec6ef0c | ||
|
704b3ee673 | ||
|
c18a1c3eca | ||
|
4e1870197e | ||
|
3bf61cce95 | ||
|
68889b0544 | ||
|
8a90a47fc2 | ||
|
eee0ccef8c | ||
|
29c593b8b0 | ||
|
71fd32b1f4 | ||
|
fcf3b4e4e2 |
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
|
8
CONTRIBUTING.md
Normal file
8
CONTRIBUTING.md
Normal file
@@ -0,0 +1,8 @@
|
||||
This is a basic checklist for now, We will update it in the future.
|
||||
|
||||
* Fork the repo and create your new branch based on the `development` branch.
|
||||
* Commit Unix line endings
|
||||
* If you want, try to keep to the theme of black holes/gravity. This can add some fun to your submission.
|
||||
* Submit Pull Requests to the development branch only.
|
||||
* Before Submitting your Pull Request, merge `development` with your new branch and fix any conflicts. (Make sure you don't break anything in development!)
|
||||
* Be patient. We will review all submitted pull requests, but our focus is on stability.. please don't be offended if we reject your PR, or it appears we're doing nothing with it! We'll get around to it..
|
13
README.md
13
README.md
@@ -1,11 +1,18 @@
|
||||
# Automated Install
|
||||
##### Designed For Raspberry Pi B, B+, 2, and Zero (with an Ethernet adapter)
|
||||
##### Designed For Raspberry Pi A+, B, B+, 2, and Zero (with an Ethernet adapter)
|
||||
|
||||
1. Install Raspbian
|
||||
2. Run the command below
|
||||
|
||||
### ```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/).
|
||||
|
||||
## Pi-hole Is Free, But Powered By Your Donations
|
||||
@@ -17,6 +24,9 @@ Once installed, [configure your router to have **DHCP clients use the Pi as thei
|
||||
[](https://vimeo.com/135965232)
|
||||
|
||||
## Pi-hole Projects
|
||||
- [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html)
|
||||
- [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/)
|
||||
- [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/)
|
||||
- [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)
|
||||
- [Sky-Hole](http://dlaa.me/blog/post/skyhole)
|
||||
@@ -26,7 +36,6 @@ Once installed, [configure your router to have **DHCP clients use the Pi as thei
|
||||
- [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole)
|
||||
|
||||
## Coverage
|
||||
- [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/)
|
||||
- [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s)
|
||||
- [MacObserver Podcast 585](http://www.macobserver.com/tmo/podcast/macgeekgab-585)
|
||||
- [Medium: Block All Ads For $53](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d)
|
||||
|
@@ -1,8 +1,46 @@
|
||||
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://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://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 - warning this one may block windows update
|
||||
#https://raw.githubusercontent.com/crazy-max/HostsWindowsBlocker/master/hosts.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
|
||||
|
||||
|
||||
# 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(){
|
||||
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
|
||||
percentBlockedToday=$(echo "scale=4; $blockedToday/$queriesToday*100" | bc)
|
||||
percentBlockedToday=$(sed 's/.\{2\}$//' <<< "$percentBlockedToday")
|
||||
if [ "$queriesToday" != 0 ]; then #Fixes divide by zero error :)
|
||||
#scale 2 rounds the number down, so we'll do scale 4 and then trim the last 2 zeros
|
||||
percentBlockedToday=$(echo "scale=4; $blockedToday/$queriesToday*100" | bc)
|
||||
percentBlockedToday=$(sed 's/.\{2\}$//' <<< "$percentBlockedToday")
|
||||
else
|
||||
percentBlockedToday=0
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -84,6 +88,7 @@ function normalChrono(){
|
||||
echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
|
||||
echo ""
|
||||
uptime | cut -d' ' -f11-
|
||||
uptime -p
|
||||
echo "-------------------------------"
|
||||
# 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;}'
|
||||
|
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
|
||||
}
|
||||
|
||||
|
||||
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() {
|
||||
# Turn the available interfaces into an array so it can be used with a whiptail dialog
|
||||
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() {
|
||||
# Let use select IPv4 and/or IPv6
|
||||
@@ -187,6 +212,7 @@ use4andor6() {
|
||||
echo "::: Exiting"
|
||||
exit 1
|
||||
fi
|
||||
cleanupIPv6
|
||||
else
|
||||
echo "::: Cancel selected. Exiting..."
|
||||
exit 1
|
||||
@@ -278,10 +304,31 @@ setStaticIPv4() {
|
||||
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(){
|
||||
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
|
||||
OpenDNS "" off)
|
||||
OpenDNS "" off
|
||||
Level3 "" off
|
||||
Norton "" off
|
||||
Comodo "" off
|
||||
Custom "" off)
|
||||
DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty)
|
||||
if [[ $? = 0 ]];then
|
||||
case $DNSchoices in
|
||||
@@ -295,6 +342,79 @@ setDNS(){
|
||||
piholeDNS1="208.67.222.222"
|
||||
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
|
||||
else
|
||||
echo "::: Cancel selected. Exiting..."
|
||||
@@ -335,8 +455,16 @@ versionCheckDNSmasq(){
|
||||
$SUDO cp $newFileToInstall $newFileFinalLocation
|
||||
echo " done."
|
||||
$SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation
|
||||
$SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation
|
||||
$SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation
|
||||
if [[ "$piholeDNS1" != "" ]]; then
|
||||
$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() {
|
||||
@@ -366,7 +494,7 @@ stopServices() {
|
||||
# Stop dnsmasq and lighttpd
|
||||
$SUDO echo ":::"
|
||||
$SUDO echo -n "::: Stopping services..."
|
||||
$SUDO service dnsmasq stop & spinner $! || true
|
||||
#$SUDO service dnsmasq stop & spinner $! || true
|
||||
$SUDO service lighttpd stop & spinner $! || true
|
||||
$SUDO echo " done."
|
||||
}
|
||||
@@ -393,7 +521,7 @@ checkForDependencies() {
|
||||
fi
|
||||
echo ":::"
|
||||
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 ":::"
|
||||
if [[ $updatesToInstall -eq "0" ]]; then
|
||||
@@ -519,21 +647,31 @@ runGravity() {
|
||||
/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
|
||||
}
|
||||
|
||||
installPihole() {
|
||||
# Install base files and web interface
|
||||
checkForDependencies # done
|
||||
stopServices
|
||||
setUser
|
||||
$SUDO mkdir -p /etc/pihole/
|
||||
$SUDO chown www-data:www-data /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
|
||||
|
||||
getGitFiles
|
||||
installScripts
|
||||
installConfigs
|
||||
#installWebAdmin
|
||||
CreateLogFile
|
||||
installPiholeWeb
|
||||
installCron
|
||||
@@ -557,6 +695,9 @@ The install log is in /etc/pihole." $r $c
|
||||
$SUDO mkdir -p /etc/pihole/
|
||||
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
|
||||
backupLegacyPihole
|
||||
# Find interfaces and let the user choose one
|
||||
@@ -575,6 +716,18 @@ $SUDO mv $tmpLog $instalLogLoc
|
||||
|
||||
displayFinalMessage
|
||||
|
||||
echo -n "::: Restarting services..."
|
||||
# Start services
|
||||
$SUDO service dnsmasq start
|
||||
$SUDO service dnsmasq restart
|
||||
$SUDO service lighttpd start
|
||||
echo " done."
|
||||
|
||||
echo ":::"
|
||||
echo "::: Installation Complete! Configure your devices to use the Pi-hole as their DNS server using:"
|
||||
echo "::: $IPv4addr"
|
||||
echo "::: $piholeIPv6"
|
||||
echo ":::"
|
||||
echo "::: If you set a new IP address, you should restart the Pi."
|
||||
echo "::: "
|
||||
echo "::: The install log is located at: /etc/pihole/install.log"
|
||||
|
||||
|
@@ -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/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")
|
||||
}
|
||||
|
30
gravity.sh
30
gravity.sh
@@ -31,6 +31,8 @@ piholeIPv6file=/etc/pihole/.useIPv6
|
||||
|
||||
adListFile=/etc/pihole/adlists.list
|
||||
adListDefault=/etc/pihole/adlists.default
|
||||
whitelistScript=/usr/local/bin/whitelist.sh
|
||||
blacklistScript=/usr/local/bin/blacklist.sh
|
||||
|
||||
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
|
||||
@@ -98,7 +100,12 @@ function gravity_collapse() {
|
||||
echo -n "::: Custom adList file detected. Reading..."
|
||||
sources=()
|
||||
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
|
||||
echo " done!"
|
||||
else
|
||||
@@ -106,7 +113,12 @@ function gravity_collapse() {
|
||||
echo -n "::: No custom adlist file detected, reading from default file..."
|
||||
sources=()
|
||||
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
|
||||
echo " done!"
|
||||
fi
|
||||
@@ -198,7 +210,7 @@ function gravity_spinup() {
|
||||
# Default is a simple request
|
||||
*) cmd_ext=""
|
||||
esac
|
||||
gravity_transport $url $cmd_ext $agent
|
||||
gravity_transport "$url" "$cmd_ext" "$agent"
|
||||
done
|
||||
}
|
||||
|
||||
@@ -220,7 +232,7 @@ function gravity_Schwarzchild() {
|
||||
function gravity_Blacklist(){
|
||||
# Append blacklist entries if they exist
|
||||
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")
|
||||
plural=; [[ "$numBlacklisted" != "1" ]] && plural=s
|
||||
@@ -245,7 +257,7 @@ function gravity_Whitelist() {
|
||||
echo " done!"
|
||||
|
||||
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")
|
||||
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
|
||||
@@ -316,11 +328,19 @@ function gravity_advanced() {
|
||||
}
|
||||
|
||||
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
|
||||
echo ":::"
|
||||
echo -n "::: Refresh lists in dnsmasq..."
|
||||
dnsmasqPid=$(pidof dnsmasq)
|
||||
|
||||
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $!
|
||||
|
||||
if [[ $dnsmasqPid ]]; then
|
||||
# service already running - reload config
|
||||
$SUDO kill -HUP $dnsmasqPid & spinner $!
|
||||
|
Reference in New Issue
Block a user