Skip to content

Commit fe05ed1

Browse files
committed
Merge pull request #314 from pi-hole/development
Pi-hole v2.5.3
2 parents 99863bb + 3a46e7f commit fe05ed1

File tree

7 files changed

+301
-26
lines changed

7 files changed

+301
-26
lines changed

adlists.default

+39-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,46 @@
1-
https://adaway.org/hosts.txt
1+
## Pi-hole ad-list default sources. Updated 21/02/2016 #########################
2+
# #
3+
# To make changes to this file: #
4+
# 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list` #
5+
# 2. run `nano /etc/pihole/adlists.list` #
6+
# 3. Uncomment or comment any of the below lists #
7+
# #
8+
# Know of any other lists? Feel free to let us know about them, or add them #
9+
# to this file! #
10+
################################################################################
11+
12+
# The below list amalgamates several lists we used previously.
13+
# See `https://github.com/StevenBlack/hosts` for details
14+
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
15+
16+
# Other lists we consider safe:
217
http://adblock.gjtech.net/?format=unix-hosts
3-
http://hosts-file.net/ad_servers.txt
4-
http://www.malwaredomainlist.com/hostslist/hosts.txt
5-
http://pgl.yoyo.org/adservers/serverlist.php?
6-
http://someonewhocares.org/hosts/hosts
7-
http://winhelp2002.mvps.org/hosts.txt
818
http://mirror1.malwaredomains.com/files/justdomains
919
http://sysctl.org/cameleon/hosts
1020
https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist
1121
https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt
1222
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
13-
http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt
23+
24+
# hosts-file.net list. Updated frequently, but has been known to block legitimate sites.
25+
http://hosts-file.net/ad_servers.txt
26+
27+
# Mahakala list. Has been known to block legitimage domains including the entire .com range.
28+
#http://adblock.mahakala.is/
29+
30+
# ADZHOSTS list. Has been known to block legitimate domains
31+
#http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt
32+
33+
# Windows 10 telemetry list - warning this one may block windows update
34+
#https://raw.githubusercontent.com/crazy-max/HostsWindowsBlocker/master/hosts.txt
35+
36+
# Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc)
37+
#http://securemecca.com/Downloads/hosts.txt
38+
39+
# Quidsup's tracker list
1440
https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt
41+
42+
43+
# Untested Lists:
44+
#https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt
45+
#http://spam404bl.com/spam404scamlist.txt
46+
#http://malwaredomains.lehigh.edu/files/domains.txt

advanced/Scripts/chronometer.sh

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ function normalChrono(){
8888
echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
8989
echo ""
9090
uptime | cut -d' ' -f11-
91+
uptime -p
9192
echo "-------------------------------"
9293
# Uncomment to continually read the log file and display the current domain being blocked
9394
#tail -f /var/log/pihole.log | awk '/\/etc\/pihole\/gravity.list/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/pihole/gravity.list") print $7; else;}'

advanced/Scripts/setupLCD.sh

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env bash
2+
# Pi-hole: A black hole for Internet advertisements
3+
# (c) 2015 by Jacob Salmela
4+
# Network-wide ad blocking via your Raspberry Pi
5+
# http://pi-hole.net
6+
# Automatically configures the Pi to use the 2.8 LCD screen to display stats on it (also works over ssh)
7+
#
8+
# Pi-hole is free software: you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation, either version 2 of the License, or
11+
# (at your option) any later version.
12+
13+
############ FUNCTIONS ###########
14+
# Run this script as root or under sudo
15+
echo ":::"
16+
if [[ $EUID -eq 0 ]];then
17+
echo "::: You are root."
18+
else
19+
echo "::: sudo will be used."
20+
# Check if it is actually installed
21+
# If it isn't, exit because the install cannot complete
22+
if [[ $(dpkg-query -s sudo) ]];then
23+
export SUDO="sudo"
24+
else
25+
echo "::: Please install sudo or run this script as root."
26+
exit 1
27+
fi
28+
fi
29+
30+
# Borrowed from adafruit-pitft-helper < borrowed from raspi-config
31+
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L324-L334
32+
getInitSys() {
33+
if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then
34+
SYSTEMD=1
35+
elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then
36+
SYSTEMD=0
37+
else
38+
echo "Unrecognised init system"
39+
return 1
40+
fi
41+
}
42+
43+
# Borrowed from adafruit-pitft-helper:
44+
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L274-L285
45+
autoLoginPiToConsole() {
46+
if [ -e /etc/init.d/lightdm ]; then
47+
if [ $SYSTEMD -eq 1 ]; then
48+
$SUDO systemctl set-default multi-user.target
49+
$SUDO ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
50+
else
51+
$SUDO update-rc.d lightdm disable 2
52+
$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/"
53+
fi
54+
fi
55+
}
56+
57+
######### SCRIPT ###########
58+
# Set pi to log in automatically
59+
getInitSys
60+
autoLoginPiToConsole
61+
62+
# Set chronomter to run automatically when pi logs in
63+
echo /usr/local/bin/chronometer.sh >> /home/pi/.bashrc
64+
# OR
65+
#$SUDO echo /usr/local/bin/chronometer.sh >> /etc/profile
66+
67+
# Set up the LCD screen based on Adafruits instuctions:
68+
# https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/easy-install
69+
curl -SLs https://apt.adafruit.com/add-pin | $SUDO bash
70+
$SUDO apt-get -y install raspberrypi-bootloader
71+
$SUDO apt-get -y install adafruit-pitft-helper
72+
$SUDO adafruit-pitft-helper -t 28r
73+
74+
# Download the cmdline.txt file that prevents the screen from going blank after a period of time
75+
$SUDO mv /boot/cmdline.txt /boot/cmdline.orig
76+
$SUDO curl -o /boot/cmdline.txt https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/cmdline.txt
77+
78+
# Back up the original file and download the new one
79+
$SUDO mv /etc/default/console-setup /etc/default/console-setup.orig
80+
$SUDO curl -o /etc/default/console-setup https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/console-setup
81+
82+
# Instantly apply the font change to the LCD screen
83+
$SUDO setupcon
84+
85+
$SUDO reboot
86+
87+
# Start showing the stats on the screen by running the command on another tty:
88+
# http://unix.stackexchange.com/questions/170063/start-a-process-on-a-different-tty
89+
#setsid sh -c 'exec /usr/local/bin/chronometer.sh <> /dev/tty1 >&0 2>&1'

advanced/cmdline.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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

advanced/console-setup

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# CONFIGURATION FILE FOR SETUPCON
2+
3+
# Consult the console-setup(5) manual page.
4+
5+
ACTIVE_CONSOLES="/dev/tty[1-6]"
6+
7+
CHARMAP="UTF-8"
8+
9+
# For best results with the Adafruit 2.8 LCD and Pi-hole's chronometer
10+
CODESET="guess"
11+
FONTFACE="Terminus"
12+
FONTSIZE="10x20"
13+
14+
VIDEOMODE=
15+
16+
# The following is an example how to use a braille font
17+
# FONT='lat9w-08.psf.gz brl-8x8.psf'

automated install/basic-install.sh

+134-17
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,20 @@ welcomeDialogs() {
117117

118118

119119
verifyFreeDiskSpace() {
120-
# 25MB is the minimum space needed (20MB install + 5MB one day of logs.)
121-
requiredFreeBytes=25600
122-
123-
existingFreeBytes=`df -lkP / | awk '{print $4}' | tail -1`
124-
125-
if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then
126-
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
127-
exit 1
128-
fi
120+
# 25MB is the minimum space needed (20MB install + 5MB one day of logs.)
121+
requiredFreeBytes=51200
122+
123+
existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1`
124+
if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then
125+
existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1`
126+
fi
127+
128+
if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then
129+
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
130+
echo "$existingFreeBytes is less than $requiredFreeBytes"
131+
echo "Insufficient free space, exiting..."
132+
exit 1
133+
fi
129134
}
130135

131136

@@ -299,10 +304,31 @@ setStaticIPv4() {
299304
fi
300305
}
301306

307+
function valid_ip()
308+
{
309+
local ip=$1
310+
local stat=1
311+
312+
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
313+
OIFS=$IFS
314+
IFS='.'
315+
ip=($ip)
316+
IFS=$OIFS
317+
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
318+
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
319+
stat=$?
320+
fi
321+
return $stat
322+
}
323+
302324
setDNS(){
303-
DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 2)
325+
DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." $r $c 6)
304326
DNSChooseOptions=(Google "" on
305-
OpenDNS "" off)
327+
OpenDNS "" off
328+
Level3 "" off
329+
Norton "" off
330+
Comodo "" off
331+
Custom "" off)
306332
DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty)
307333
if [[ $? = 0 ]];then
308334
case $DNSchoices in
@@ -316,6 +342,79 @@ setDNS(){
316342
piholeDNS1="208.67.222.222"
317343
piholeDNS2="208.67.220.220"
318344
;;
345+
Level3)
346+
echo "::: Using Level3 servers."
347+
piholeDNS1="4.2.2.1"
348+
piholeDNS2="4.2.2.2"
349+
;;
350+
Norton)
351+
echo "::: Using Norton ConnectSafe servers."
352+
piholeDNS1="199.85.126.10"
353+
piholeDNS2="199.85.127.10"
354+
;;
355+
Comodo)
356+
echo "::: Using Comodo Secure servers."
357+
piholeDNS1="8.26.56.26"
358+
piholeDNS2="8.20.247.20"
359+
;;
360+
Custom)
361+
until [[ $DNSSettingsCorrect = True ]]
362+
do
363+
364+
strInvalid="Invalid"
365+
366+
if [ ! $piholeDNS1 ]; then
367+
if [ ! $piholeDNS2 ]; then
368+
prePopulate=""
369+
else
370+
prePopulate=", $piholeDNS2"
371+
fi
372+
elif [ $piholeDNS1 ] && [ ! $piholeDNS2 ]; then
373+
prePopulate="$piholeDNS1"
374+
elif [ $piholeDNS1 ] && [ $piholeDNS2 ]; then
375+
prePopulate="$piholeDNS1, $piholeDNS2"
376+
fi
377+
378+
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)
379+
if [[ $? = 0 ]];then
380+
piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}')
381+
piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}')
382+
383+
if ! valid_ip $piholeDNS1 || [ ! $piholeDNS1 ]; then
384+
piholeDNS1=$strInvalid
385+
fi
386+
387+
if ! valid_ip $piholeDNS2 && [ $piholeDNS2 ]; then
388+
piholeDNS2=$strInvalid
389+
fi
390+
391+
else
392+
echo "::: Cancel selected, exiting...."
393+
exit 1
394+
fi
395+
396+
if [[ $piholeDNS1 == $strInvalid ]] || [[ $piholeDNS2 == $strInvalid ]]; then
397+
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
398+
399+
if [[ $piholeDNS1 == $strInvalid ]]; then
400+
piholeDNS1=""
401+
fi
402+
403+
if [[ $piholeDNS2 == $strInvalid ]]; then
404+
piholeDNS2=""
405+
fi
406+
407+
DNSSettingsCorrect=False
408+
else
409+
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
410+
DNSSettingsCorrect=True
411+
else
412+
# If the settings are wrong, the loop continues
413+
DNSSettingsCorrect=False
414+
fi
415+
fi
416+
done
417+
;;
319418
esac
320419
else
321420
echo "::: Cancel selected. Exiting..."
@@ -356,8 +455,16 @@ versionCheckDNSmasq(){
356455
$SUDO cp $newFileToInstall $newFileFinalLocation
357456
echo " done."
358457
$SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation
359-
$SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation
360-
$SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation
458+
if [[ "$piholeDNS1" != "" ]]; then
459+
$SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation
460+
else
461+
$SUDO sed -i '/^server=@DNS1@/d' $newFileFinalLocation
462+
fi
463+
if [[ "$piholeDNS2" != "" ]]; then
464+
$SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation
465+
else
466+
$SUDO sed -i '/^server=@DNS2@/d' $newFileFinalLocation
467+
fi
361468
}
362469

363470
installScripts() {
@@ -387,7 +494,7 @@ stopServices() {
387494
# Stop dnsmasq and lighttpd
388495
$SUDO echo ":::"
389496
$SUDO echo -n "::: Stopping services..."
390-
$SUDO service dnsmasq stop & spinner $! || true
497+
#$SUDO service dnsmasq stop & spinner $! || true
391498
$SUDO service lighttpd stop & spinner $! || true
392499
$SUDO echo " done."
393500
}
@@ -540,21 +647,31 @@ runGravity() {
540647
/usr/local/bin/gravity.sh
541648
}
542649

650+
setUser(){
651+
# Check if user pihole exists and create if not
652+
echo "::: Checking if user 'pihole' exists..."
653+
if id -u pihole > /dev/null 2>&1; then
654+
echo "::: User 'pihole' already exists"
655+
else
656+
echo "::: User 'pihole' doesn't exist. Creating..."
657+
$SUDO useradd -r -s /usr/sbin/nologin pihole
658+
fi
659+
}
543660

544661
installPihole() {
545662
# Install base files and web interface
546663
checkForDependencies # done
547664
stopServices
665+
setUser
548666
$SUDO mkdir -p /etc/pihole/
549667
$SUDO chown www-data:www-data /var/www/html
550668
$SUDO chmod 775 /var/www/html
551-
$SUDO usermod -a -G www-data pi
669+
$SUDO usermod -a -G www-data pihole
552670
$SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null
553671

554672
getGitFiles
555673
installScripts
556674
installConfigs
557-
#installWebAdmin
558675
CreateLogFile
559676
installPiholeWeb
560677
installCron
@@ -601,7 +718,7 @@ displayFinalMessage
601718

602719
echo -n "::: Restarting services..."
603720
# Start services
604-
$SUDO service dnsmasq start
721+
$SUDO service dnsmasq restart
605722
$SUDO service lighttpd start
606723
echo " done."
607724

0 commit comments

Comments
 (0)