mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-11 00:20:55 +00:00
Merge branch 'development' into customblockpage
Conflicts: automated install/basic-install.sh
This commit is contained in:
commit
bb28d94884
@ -28,7 +28,7 @@ https://hosts-file.net/ad_servers.txt
|
|||||||
#http://adblock.mahakala.is/
|
#http://adblock.mahakala.is/
|
||||||
|
|
||||||
# ADZHOSTS list. Has been known to block legitimate domains
|
# ADZHOSTS list. Has been known to block legitimate domains
|
||||||
#http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt
|
#http://pilotfiber.dl.sourceforge.net/project/adzhosts/HOSTS.txt
|
||||||
|
|
||||||
# Windows 10 telemetry list
|
# Windows 10 telemetry list
|
||||||
#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/win10/spy.txt
|
#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/win10/spy.txt
|
||||||
|
@ -20,13 +20,8 @@
|
|||||||
# OR IN /etc/dnsmasq.conf #
|
# OR IN /etc/dnsmasq.conf #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
address=/pi.hole/@IPv4@
|
|
||||||
address=/pi.hole/@IPv6@
|
|
||||||
|
|
||||||
address=/@HOSTNAME@/@IPv4@
|
|
||||||
address=/@HOSTNAME@/@IPv6@
|
|
||||||
|
|
||||||
addn-hosts=/etc/pihole/gravity.list
|
addn-hosts=/etc/pihole/gravity.list
|
||||||
|
addn-hosts=/etc/pihole/local.list
|
||||||
|
|
||||||
domain-needed
|
domain-needed
|
||||||
|
|
||||||
|
@ -19,8 +19,9 @@ helpFunc() {
|
|||||||
:::
|
:::
|
||||||
::: Options:
|
::: Options:
|
||||||
::: -p, password Set web interface password, an empty input will remove any previously set password
|
::: -p, password Set web interface password, an empty input will remove any previously set password
|
||||||
::: -c, celsius Set Celcius temperature unit
|
::: -c, celsius Set Celsius temperature unit
|
||||||
::: -f, fahrenheit Set Fahrenheit temperature unit
|
::: -f, fahrenheit Set Fahrenheit temperature unit
|
||||||
|
::: -k, kelvin Set Kelvin temperature unit
|
||||||
::: -h, --help Show this help dialog
|
::: -h, --help Show this help dialog
|
||||||
EOM
|
EOM
|
||||||
exit 0
|
exit 0
|
||||||
@ -31,16 +32,24 @@ SetTemperatureUnit(){
|
|||||||
# Remove setting from file (create backup setupVars.conf.bak)
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
sed -i.bak '/TEMPERATUREUNIT/d' /etc/pihole/setupVars.conf
|
sed -i.bak '/TEMPERATUREUNIT/d' /etc/pihole/setupVars.conf
|
||||||
# Save setting to file
|
# Save setting to file
|
||||||
if [[ $unit == "F" ]] ; then
|
echo "TEMPERATUREUNIT=${unit}" >> /etc/pihole/setupVars.conf
|
||||||
echo "TEMPERATUREUNIT=F" >> /etc/pihole/setupVars.conf
|
|
||||||
else
|
|
||||||
echo "TEMPERATUREUNIT=C" >> /etc/pihole/setupVars.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetWebPassword(){
|
SetWebPassword(){
|
||||||
|
|
||||||
|
if [ "${SUDO_USER}" == "www-data" ]; then
|
||||||
|
echo "Security measure: user www-data is not allowed to change webUI password!"
|
||||||
|
echo "Exiting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${SUDO_USER}" == "lighttpd" ]; then
|
||||||
|
echo "Security measure: user lighttpd is not allowed to change webUI password!"
|
||||||
|
echo "Exiting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove password from file (create backup setupVars.conf.bak)
|
# Remove password from file (create backup setupVars.conf.bak)
|
||||||
sed -i.bak '/WEBPASSWORD/d' /etc/pihole/setupVars.conf
|
sed -i.bak '/WEBPASSWORD/d' /etc/pihole/setupVars.conf
|
||||||
# Set password only if there is one to be set
|
# Set password only if there is one to be set
|
||||||
@ -57,14 +66,173 @@ SetWebPassword(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for var in "$@"; do
|
SetDNSServers(){
|
||||||
case "${var}" in
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/DNS_FQDN_REQUIRED/d;' /etc/pihole/setupVars.conf
|
||||||
|
# Save setting to file
|
||||||
|
echo "PIHOLE_DNS_1=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
if [[ "${args[3]}" != "none" ]]; then
|
||||||
|
echo "PIHOLE_DNS_2=${args[3]}" >> /etc/pihole/setupVars.conf
|
||||||
|
else
|
||||||
|
echo "PIHOLE_DNS_2=" >> /etc/pihole/setupVars.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Replace within actual dnsmasq config file
|
||||||
|
sed -i '/server=/d;' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
echo "server=${args[2]}" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
if [[ "${args[3]}" != "none" ]]; then
|
||||||
|
echo "server=${args[3]}" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove domain-needed entry
|
||||||
|
sed -i '/domain-needed/d;' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
|
||||||
|
# Readd it if required
|
||||||
|
if [[ "${args[4]}" == "domain-needed" ]]; then
|
||||||
|
echo "domain-needed" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
echo "DNS_FQDN_REQUIRED=true" >> /etc/pihole/setupVars.conf
|
||||||
|
else
|
||||||
|
# Leave it deleted if not wanted
|
||||||
|
echo "DNS_FQDN_REQUIRED=false" >> /etc/pihole/setupVars.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove bogus-priv entry
|
||||||
|
sed -i '/bogus-priv/d;' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
|
||||||
|
# Readd it if required
|
||||||
|
if [[ "${args[5]}" == "bogus-priv" ]]; then
|
||||||
|
echo "bogus-priv" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
echo "DNS_BOGUS_PRIV=true" >> /etc/pihole/setupVars.conf
|
||||||
|
else
|
||||||
|
# Leave it deleted if not wanted
|
||||||
|
echo "DNS_BOGUS_PRIV=false" >> /etc/pihole/setupVars.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Restart dnsmasq to load new configuration
|
||||||
|
RestartDNS
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SetExcludeDomains(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/API_EXCLUDE_DOMAINS/d;' /etc/pihole/setupVars.conf
|
||||||
|
# Save setting to file
|
||||||
|
echo "API_EXCLUDE_DOMAINS=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
SetExcludeClients(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/API_EXCLUDE_CLIENTS/d;' /etc/pihole/setupVars.conf
|
||||||
|
# Save setting to file
|
||||||
|
echo "API_EXCLUDE_CLIENTS=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
Reboot(){
|
||||||
|
|
||||||
|
nohup bash -c "sleep 5; reboot" &> /dev/null </dev/null &
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
RestartDNS(){
|
||||||
|
|
||||||
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl restart dnsmasq &> /dev/null
|
||||||
|
else
|
||||||
|
service dnsmasq restart &> /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SetQueryLogOptions(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/API_QUERY_LOG_SHOW/d;' /etc/pihole/setupVars.conf
|
||||||
|
# Save setting to file
|
||||||
|
echo "API_QUERY_LOG_SHOW=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
EnableDHCP(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/DHCP_/d;' /etc/pihole/setupVars.conf
|
||||||
|
echo "DHCP_ACTIVE=true" >> /etc/pihole/setupVars.conf
|
||||||
|
echo "DHCP_START=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
echo "DHCP_END=${args[3]}" >> /etc/pihole/setupVars.conf
|
||||||
|
echo "DHCP_ROUTER=${args[4]}" >> /etc/pihole/setupVars.conf
|
||||||
|
|
||||||
|
# Remove setting from file
|
||||||
|
sed -i '/dhcp-/d;/quiet-dhcp/d;' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
# Save setting to file
|
||||||
|
echo "dhcp-range=${args[2]},${args[3]},infinite" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
echo "dhcp-option=option:router,${args[4]}" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
# Changes the behaviour from strict RFC compliance so that DHCP requests on unknown leases from unknown hosts are not ignored. This allows new hosts to get a lease without a tedious timeout under all circumstances. It also allows dnsmasq to rebuild its lease database without each client needing to reacquire a lease, if the database is lost.
|
||||||
|
echo "dhcp-authoritative" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
# Use the specified file to store DHCP lease information
|
||||||
|
echo "dhcp-leasefile=/etc/pihole/dhcp.leases" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
# Suppress logging of the routine operation of these protocols. Errors and problems will still be logged, though.
|
||||||
|
echo "quiet-dhcp" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
echo "quiet-dhcp6" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
|
||||||
|
RestartDNS
|
||||||
|
}
|
||||||
|
|
||||||
|
DisableDHCP(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/DHCP_ACTIVE/d;' /etc/pihole/setupVars.conf
|
||||||
|
echo "DHCP_ACTIVE=false" >> /etc/pihole/setupVars.conf
|
||||||
|
|
||||||
|
# Remove setting from file
|
||||||
|
sed -i '/dhcp-/d;/quiet-dhcp/d;' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
|
||||||
|
RestartDNS
|
||||||
|
}
|
||||||
|
|
||||||
|
SetWebUILayout(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/WEBUIBOXEDLAYOUT/d;' /etc/pihole/setupVars.conf
|
||||||
|
echo "WEBUIBOXEDLAYOUT=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDNSDomainName(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/PIHOLE_DOMAIN/d;' /etc/pihole/setupVars.conf
|
||||||
|
# Save setting to file
|
||||||
|
echo "PIHOLE_DOMAIN=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
|
||||||
|
# Replace within actual dnsmasq config file
|
||||||
|
sed -i '/domain=/d;' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
echo "domain=${args[2]}" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
|
||||||
|
# Restart dnsmasq to load new configuration
|
||||||
|
RestartDNS
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
case "${args[1]}" in
|
||||||
"-p" | "password" ) SetWebPassword;;
|
"-p" | "password" ) SetWebPassword;;
|
||||||
"-c" | "celsius" ) unit="C"; SetTemperatureUnit;;
|
"-c" | "celsius" ) unit="C"; SetTemperatureUnit;;
|
||||||
"-f" | "fahrenheit" ) unit="F"; SetTemperatureUnit;;
|
"-f" | "fahrenheit" ) unit="F"; SetTemperatureUnit;;
|
||||||
|
"-k" | "kelvin" ) unit="K"; SetTemperatureUnit;;
|
||||||
|
"setdns" ) SetDNSServers;;
|
||||||
|
"setexcludedomains" ) SetExcludeDomains;;
|
||||||
|
"setexcludeclients" ) SetExcludeClients;;
|
||||||
|
"reboot" ) Reboot;;
|
||||||
|
"restartdns" ) RestartDNS;;
|
||||||
|
"setquerylog" ) SetQueryLogOptions;;
|
||||||
|
"enabledhcp" ) EnableDHCP;;
|
||||||
|
"disabledhcp" ) DisableDHCP;;
|
||||||
|
"layout" ) SetWebUILayout;;
|
||||||
"-h" | "--help" ) helpFunc;;
|
"-h" | "--help" ) helpFunc;;
|
||||||
|
"domainname" ) SetDNSDomainName;;
|
||||||
|
* ) helpFunc;;
|
||||||
esac
|
esac
|
||||||
done
|
|
||||||
|
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ _pihole() {
|
|||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
opts="blacklist chronometer debug flush help query reconfigure setupLCD uninstall updateGravity updatePihole version whitelist"
|
opts="admin blacklist chronometer debug disable enable flush help logging query reconfigure restartdns setupLCD status tail uninstall updateGravity updatePihole version whitelist"
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
# Pi-hole: Update the ad sources once a week on Sunday at 01:59
|
# Pi-hole: Update the ad sources once a week on Sunday at 01:59
|
||||||
# Download any updates from the adlists
|
# Download any updates from the adlists
|
||||||
59 1 * * 7 root /usr/local/bin/pihole updateGravity
|
59 1 * * 7 root PATH="$PATH:/usr/local/bin/" pihole updateGravity
|
||||||
|
|
||||||
# Pi-hole: Update Pi-hole! Uncomment to enable auto update
|
# Pi-hole: Update Pi-hole! Uncomment to enable auto update
|
||||||
#30 2 * * 7 root /usr/local/bin/pihole updatePihole
|
#30 2 * * 7 root PATH="$PATH:/usr/local/bin/" pihole updatePihole
|
||||||
|
|
||||||
# Pi-hole: Flush the log daily at 00:00 so it doesn't get out of control
|
# Pi-hole: Flush the log daily at 00:00 so it doesn't get out of control
|
||||||
# Stats will be viewable in the Web interface thanks to the cron job above
|
# Stats will be viewable in the Web interface thanks to the cron job above
|
||||||
00 00 * * * root /usr/local/bin/pihole flush
|
00 00 * * * root PATH="$PATH:/usr/local/bin/" pihole flush
|
||||||
|
@ -81,8 +81,7 @@ if [[ $(command -v apt-get) ]]; then
|
|||||||
PKG_MANAGER="apt-get"
|
PKG_MANAGER="apt-get"
|
||||||
PKG_CACHE="/var/lib/apt/lists/"
|
PKG_CACHE="/var/lib/apt/lists/"
|
||||||
UPDATE_PKG_CACHE="${PKG_MANAGER} update"
|
UPDATE_PKG_CACHE="${PKG_MANAGER} update"
|
||||||
PKG_UPDATE="${PKG_MANAGER} upgrade"
|
PKG_INSTALL="${PKG_MANAGER} --yes --no-install-recommends install"
|
||||||
PKG_INSTALL="${PKG_MANAGER} --yes --fix-missing install"
|
|
||||||
# grep -c will return 1 retVal on 0 matches, block this throwing the set -e with an OR TRUE
|
# grep -c will return 1 retVal on 0 matches, block this throwing the set -e with an OR TRUE
|
||||||
PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true"
|
PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true"
|
||||||
# #########################################
|
# #########################################
|
||||||
@ -92,8 +91,8 @@ if [[ $(command -v apt-get) ]]; then
|
|||||||
# Prefer the php metapackage if it's there, fall back on the php5 pacakges
|
# Prefer the php metapackage if it's there, fall back on the php5 pacakges
|
||||||
${PKG_MANAGER} install --dry-run php > /dev/null 2>&1 && phpVer="php" || phpVer="php5"
|
${PKG_MANAGER} install --dry-run php > /dev/null 2>&1 && phpVer="php" || phpVer="php5"
|
||||||
# #########################################
|
# #########################################
|
||||||
INSTALLER_DEPS=( apt-utils whiptail git dhcpcd5)
|
INSTALLER_DEPS=(apt-utils debconf dhcpcd5 git whiptail)
|
||||||
PIHOLE_DEPS=( iputils-ping lsof dnsutils bc dnsmasq lighttpd ${phpVer}-common ${phpVer}-cgi curl unzip wget sudo netcat cron ${IPROUTE_PKG} )
|
PIHOLE_DEPS=(bc cron curl dnsmasq dnsutils ${IPROUTE_PKG} iputils-ping lighttpd lsof netcat ${phpVer}-common ${phpVer}-cgi sudo unzip wget)
|
||||||
LIGHTTPD_USER="www-data"
|
LIGHTTPD_USER="www-data"
|
||||||
LIGHTTPD_GROUP="www-data"
|
LIGHTTPD_GROUP="www-data"
|
||||||
LIGHTTPD_CFG="lighttpd.conf.debian"
|
LIGHTTPD_CFG="lighttpd.conf.debian"
|
||||||
@ -111,11 +110,10 @@ elif [ $(command -v rpm) ]; then
|
|||||||
fi
|
fi
|
||||||
PKG_CACHE="/var/cache/${PKG_MANAGER}"
|
PKG_CACHE="/var/cache/${PKG_MANAGER}"
|
||||||
UPDATE_PKG_CACHE="${PKG_MANAGER} check-update"
|
UPDATE_PKG_CACHE="${PKG_MANAGER} check-update"
|
||||||
PKG_UPDATE="${PKG_MANAGER} update -y"
|
|
||||||
PKG_INSTALL="${PKG_MANAGER} install -y"
|
PKG_INSTALL="${PKG_MANAGER} install -y"
|
||||||
PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l"
|
PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l"
|
||||||
INSTALLER_DEPS=( iproute net-tools procps-ng newt git )
|
INSTALLER_DEPS=(git iproute net-tools newt procps-ng)
|
||||||
PIHOLE_DEPS=( epel-release bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php curl unzip wget findutils cronie sudo nmap-ncat )
|
PIHOLE_DEPS=(bc bind-utils cronie curl dnsmasq epel-release findutils lighttpd lighttpd-fastcgi nmap-ncat php php-common php-cli sudo unzip wget)
|
||||||
|
|
||||||
if grep -q 'Fedora' /etc/redhat-release; then
|
if grep -q 'Fedora' /etc/redhat-release; then
|
||||||
remove_deps=(epel-release);
|
remove_deps=(epel-release);
|
||||||
@ -135,26 +133,11 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
####### FUNCTIONS ##########
|
####### FUNCTIONS ##########
|
||||||
spinner() {
|
|
||||||
local pid=$1
|
|
||||||
local delay=0.50
|
|
||||||
local spinstr='/-\|'
|
|
||||||
|
|
||||||
while [ "$(ps a | awk '{print $1}' | grep "${pid}")" ]; do
|
|
||||||
local temp=${spinstr#?}
|
|
||||||
printf " [%c] " "${spinstr}"
|
|
||||||
local spinstr=${temp}${spinstr%"$temp"}
|
|
||||||
sleep ${delay}
|
|
||||||
printf "\b\b\b\b\b\b"
|
|
||||||
done
|
|
||||||
printf " \b\b\b\b"
|
|
||||||
}
|
|
||||||
|
|
||||||
is_repo() {
|
is_repo() {
|
||||||
# Use git to check if directory is currently under VCS, return the value
|
# Use git to check if directory is currently under VCS, return the value
|
||||||
local directory="${1}"
|
local directory="${1}"
|
||||||
git -C "${directory}" status --short &> /dev/null
|
curdir=$PWD; cd $directory; git status --short &> /dev/null; rc=$?; cd $curdir
|
||||||
return
|
return $rc
|
||||||
}
|
}
|
||||||
|
|
||||||
make_repo() {
|
make_repo() {
|
||||||
@ -163,7 +146,7 @@ make_repo() {
|
|||||||
# Remove the non-repod interface and clone the interface
|
# Remove the non-repod interface and clone the interface
|
||||||
echo -n "::: Cloning $remoteRepo into $directory..."
|
echo -n "::: Cloning $remoteRepo into $directory..."
|
||||||
rm -rf "${directory}"
|
rm -rf "${directory}"
|
||||||
git clone -q --depth 1 "${remoteRepo}" "${directory}" > /dev/null & spinner $!
|
git clone -q --depth 1 "${remoteRepo}" "${directory}" &> /dev/null
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,8 +155,8 @@ update_repo() {
|
|||||||
# Pull the latest commits
|
# Pull the latest commits
|
||||||
echo -n "::: Updating repo in $1..."
|
echo -n "::: Updating repo in $1..."
|
||||||
cd "${directory}" || exit 1
|
cd "${directory}" || exit 1
|
||||||
git stash -q > /dev/null & spinner $!
|
git stash -q &> /dev/null
|
||||||
git pull -q > /dev/null & spinner $!
|
git pull -q &> /dev/null
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,9 +226,7 @@ verifyFreeDiskSpace() {
|
|||||||
|
|
||||||
echo "Insufficient free space, exiting..."
|
echo "Insufficient free space, exiting..."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -298,7 +279,7 @@ use4andor6() {
|
|||||||
# Let use select IPv4 and/or IPv6
|
# Let use select IPv4 and/or IPv6
|
||||||
cmd=(whiptail --separate-output --checklist "Select Protocols (press space to select)" ${r} ${c} 2)
|
cmd=(whiptail --separate-output --checklist "Select Protocols (press space to select)" ${r} ${c} 2)
|
||||||
options=(IPv4 "Block ads over IPv4" on
|
options=(IPv4 "Block ads over IPv4" on
|
||||||
IPv6 "Block ads over IPv6" off)
|
IPv6 "Block ads over IPv6" on)
|
||||||
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
|
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
|
||||||
if [[ $? = 0 ]];then
|
if [[ $? = 0 ]];then
|
||||||
for choice in ${choices}
|
for choice in ${choices}
|
||||||
@ -613,36 +594,6 @@ version_check_dnsmasq() {
|
|||||||
sed -i '/^server=@DNS2@/d' ${dnsmasq_pihole_01_location}
|
sed -i '/^server=@DNS2@/d' ${dnsmasq_pihole_01_location}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#sed -i "s/@HOSTNAME@/$hostname/" ${dnsmasq_pihole_01_location}
|
|
||||||
|
|
||||||
if [[ -f /etc/hostname ]]; then
|
|
||||||
hostname=$(</etc/hostname)
|
|
||||||
elif [ -x "$(command -v hostname)" ]; then
|
|
||||||
hostname=$(hostname -f)
|
|
||||||
fi
|
|
||||||
|
|
||||||
#Replace IPv4 and IPv6 tokens in 01-pihole.conf for pi.hole resolution.
|
|
||||||
if [[ "${IPV4_ADDRESS}" != "" ]]; then
|
|
||||||
tmp=${IPV4_ADDRESS%/*}
|
|
||||||
sed -i "s/@IPv4@/$tmp/" ${dnsmasq_pihole_01_location}
|
|
||||||
else
|
|
||||||
sed -i '/^address=\/pi.hole\/@IPv4@/d' ${dnsmasq_pihole_01_location}
|
|
||||||
sed -i '/^address=\/@HOSTNAME@\/@IPv4@/d' ${dnsmasq_pihole_01_location}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${IPV6_ADDRESS}" != "" ]]; then
|
|
||||||
sed -i "s/@IPv6@/$IPV6_ADDRESS/" ${dnsmasq_pihole_01_location}
|
|
||||||
else
|
|
||||||
sed -i '/^address=\/pi.hole\/@IPv6@/d' ${dnsmasq_pihole_01_location}
|
|
||||||
sed -i '/^address=\/@HOSTNAME@\/@IPv6@/d' ${dnsmasq_pihole_01_location}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${hostname}" != "" ]]; then
|
|
||||||
sed -i "s/@HOSTNAME@/$hostname/" ${dnsmasq_pihole_01_location}
|
|
||||||
else
|
|
||||||
sed -i '/^address=\/@HOSTNAME@*/d' ${dnsmasq_pihole_01_location}
|
|
||||||
fi
|
|
||||||
|
|
||||||
sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' ${dnsmasq_conf}
|
sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' ${dnsmasq_conf}
|
||||||
|
|
||||||
if [[ "${QUERY_LOGGING}" == false ]] ; then
|
if [[ "${QUERY_LOGGING}" == false ]] ; then
|
||||||
@ -654,16 +605,6 @@ version_check_dnsmasq() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_legacy_scripts() {
|
|
||||||
#Tidy up /usr/local/bin directory if installing over previous install.
|
|
||||||
oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard uninstall setupLCD piholeDebug)
|
|
||||||
for i in "${oldFiles[@]}"; do
|
|
||||||
if [ -f "/usr/local/bin/$i.sh" ]; then
|
|
||||||
rm /usr/local/bin/"$i".sh
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
clean_existing() {
|
clean_existing() {
|
||||||
# Clean an exiting installation to prepare for upgrade/reinstall
|
# Clean an exiting installation to prepare for upgrade/reinstall
|
||||||
# ${1} Directory to clean; ${2} Array of files to remove
|
# ${1} Directory to clean; ${2} Array of files to remove
|
||||||
@ -673,7 +614,6 @@ clean_existing() {
|
|||||||
for script in "${old_files[@]}"; do
|
for script in "${old_files[@]}"; do
|
||||||
rm -f "${clean_directory}${script}.sh"
|
rm -f "${clean_directory}${script}.sh"
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
installScripts() {
|
installScripts() {
|
||||||
@ -689,6 +629,7 @@ installScripts() {
|
|||||||
# Install files from local core repository
|
# Install files from local core repository
|
||||||
if is_repo "${PI_HOLE_LOCAL_REPO}"; then
|
if is_repo "${PI_HOLE_LOCAL_REPO}"; then
|
||||||
cd "${PI_HOLE_LOCAL_REPO}"
|
cd "${PI_HOLE_LOCAL_REPO}"
|
||||||
|
install -o "${USER}" -Dm755 -d /opt/pihole
|
||||||
install -o "${USER}" -Dm755 -t /opt/pihole/ gravity.sh
|
install -o "${USER}" -Dm755 -t /opt/pihole/ gravity.sh
|
||||||
install -o "${USER}" -Dm755 -t /opt/pihole/ ./advanced/Scripts/*.sh
|
install -o "${USER}" -Dm755 -t /opt/pihole/ ./advanced/Scripts/*.sh
|
||||||
install -o "${USER}" -Dm755 -t /opt/pihole/ ./automated\ install/uninstall.sh
|
install -o "${USER}" -Dm755 -t /opt/pihole/ ./automated\ install/uninstall.sh
|
||||||
@ -710,9 +651,9 @@ installConfigs() {
|
|||||||
mkdir /etc/lighttpd
|
mkdir /etc/lighttpd
|
||||||
chown "${USER}":root /etc/lighttpd
|
chown "${USER}":root /etc/lighttpd
|
||||||
elif [ -f "/etc/lighttpd/lighttpd.conf" ]; then
|
elif [ -f "/etc/lighttpd/lighttpd.conf" ]; then
|
||||||
mv ${lighttpdConfig} ${lighttpdConfig}.orig
|
mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
||||||
fi
|
fi
|
||||||
cp /etc/.pihole/advanced/${LIGHTTPD_CFG} ${lighttpdConfig}
|
cp /etc/.pihole/advanced/${LIGHTTPD_CFG} /etc/lighttpd/lighttpd.conf
|
||||||
mkdir -p /var/run/lighttpd
|
mkdir -p /var/run/lighttpd
|
||||||
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/run/lighttpd
|
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/run/lighttpd
|
||||||
mkdir -p /var/cache/lighttpd/compress
|
mkdir -p /var/cache/lighttpd/compress
|
||||||
@ -727,9 +668,9 @@ stop_service() {
|
|||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Stopping ${1} service..."
|
echo -n "::: Stopping ${1} service..."
|
||||||
if [ -x "$(command -v systemctl)" ]; then
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
systemctl stop "${1}" &> /dev/null & spinner $! || true
|
systemctl stop "${1}" &> /dev/null || true
|
||||||
else
|
else
|
||||||
service "${1}" stop &> /dev/null & spinner $! || true
|
service "${1}" stop &> /dev/null || true
|
||||||
fi
|
fi
|
||||||
echo " done."
|
echo " done."
|
||||||
}
|
}
|
||||||
@ -740,9 +681,9 @@ start_service() {
|
|||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Starting ${1} service..."
|
echo -n "::: Starting ${1} service..."
|
||||||
if [ -x "$(command -v systemctl)" ]; then
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
systemctl restart "${1}" &> /dev/null & spinner $!
|
systemctl restart "${1}" &> /dev/null
|
||||||
else
|
else
|
||||||
service "${1}" restart &> /dev/null & spinner $!
|
service "${1}" restart &> /dev/null
|
||||||
fi
|
fi
|
||||||
echo " done."
|
echo " done."
|
||||||
}
|
}
|
||||||
@ -752,9 +693,9 @@ enable_service() {
|
|||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Enabling ${1} service to start on reboot..."
|
echo -n "::: Enabling ${1} service to start on reboot..."
|
||||||
if [ -x "$(command -v systemctl)" ]; then
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
systemctl enable "${1}" &> /dev/null & spinner $!
|
systemctl enable "${1}" &> /dev/null
|
||||||
else
|
else
|
||||||
update-rc.d "${1}" defaults &> /dev/null & spinner $!
|
update-rc.d "${1}" defaults &> /dev/null
|
||||||
fi
|
fi
|
||||||
echo " done."
|
echo " done."
|
||||||
}
|
}
|
||||||
@ -773,7 +714,7 @@ update_pacakge_cache() {
|
|||||||
#update package lists
|
#update package lists
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: ${PKG_MANAGER} update has not been run today. Running now..."
|
echo -n "::: ${PKG_MANAGER} update has not been run today. Running now..."
|
||||||
${UPDATE_PKG_CACHE} &> /dev/null & spinner $!
|
${UPDATE_PKG_CACHE} &> /dev/null
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -790,7 +731,7 @@ notify_package_updates_available() {
|
|||||||
echo "::: Your system is up to date! Continuing with Pi-hole installation..."
|
echo "::: Your system is up to date! Continuing with Pi-hole installation..."
|
||||||
else
|
else
|
||||||
echo "::: There are ${updatesToInstall} updates available for your system!"
|
echo "::: There are ${updatesToInstall} updates available for your system!"
|
||||||
echo "::: We recommend you run '${PKG_UPDATE}' after installing Pi-Hole! "
|
echo "::: We recommend you update your OS after installing Pi-Hole! "
|
||||||
echo ":::"
|
echo ":::"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -800,11 +741,15 @@ install_dependent_packages() {
|
|||||||
# No spinner - conflicts with set -e
|
# No spinner - conflicts with set -e
|
||||||
declare -a argArray1=("${!1}")
|
declare -a argArray1=("${!1}")
|
||||||
|
|
||||||
|
if command -v debconf-apt-progress &> /dev/null; then
|
||||||
|
debconf-apt-progress -- ${PKG_INSTALL} "${argArray1[@]}"
|
||||||
|
else
|
||||||
for i in "${argArray1[@]}"; do
|
for i in "${argArray1[@]}"; do
|
||||||
echo -n "::: Checking for $i..."
|
echo -n "::: Checking for $i..."
|
||||||
package_check_install "${i}" &> /dev/null
|
package_check_install "${i}" &> /dev/null
|
||||||
echo " installed!"
|
echo " installed!"
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateLogFile() {
|
CreateLogFile() {
|
||||||
@ -911,9 +856,9 @@ configureFirewall() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
finalExports() {
|
finalExports() {
|
||||||
#If it already exists, lets overwrite it with the new values.
|
# Update variables in setupVars.conf file
|
||||||
if [[ -f ${setupVars} ]]; then
|
if [ -e "${setupVars}" ]; then
|
||||||
rm ${setupVars}
|
sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/QUERY_LOGGING/d;' "${setupVars}"
|
||||||
fi
|
fi
|
||||||
{
|
{
|
||||||
echo "PIHOLE_INTERFACE=${PIHOLE_INTERFACE}"
|
echo "PIHOLE_INTERFACE=${PIHOLE_INTERFACE}"
|
||||||
@ -954,13 +899,12 @@ accountForRefactor() {
|
|||||||
# At some point in the future this list can be pruned, for now we'll need it to ensure updates don't break.
|
# At some point in the future this list can be pruned, for now we'll need it to ensure updates don't break.
|
||||||
|
|
||||||
# Refactoring of install script has changed the name of a couple of variables. Sort them out here.
|
# Refactoring of install script has changed the name of a couple of variables. Sort them out here.
|
||||||
sed -i 's/IPv4addr/IPv4_address/g' ${setupVars}
|
|
||||||
sed -i 's/piholeIPv6/IPv6_address/g' ${setupVars}
|
|
||||||
|
|
||||||
# Account for renaming of global variables.
|
|
||||||
sed -i 's/piholeInterface/PIHOLE_INTERFACE/g' ${setupVars}
|
sed -i 's/piholeInterface/PIHOLE_INTERFACE/g' ${setupVars}
|
||||||
sed -i 's/IPv4_address/IPV4_ADDRESS/g' ${setupVars}
|
sed -i 's/IPv4_address/IPV4_ADDRESS/g' ${setupVars}
|
||||||
|
sed -i 's/IPv4addr/IPV4_ADDRESS/g' ${setupVars}
|
||||||
sed -i 's/IPv6_address/IPV6_ADDRESS/g' ${setupVars}
|
sed -i 's/IPv6_address/IPV6_ADDRESS/g' ${setupVars}
|
||||||
|
sed -i 's/piholeIPv6/IPV6_ADDRESS/g' ${setupVars}
|
||||||
sed -i 's/piholeDNS1/PIHOLE_DNS_1/g' ${setupVars}
|
sed -i 's/piholeDNS1/PIHOLE_DNS_1/g' ${setupVars}
|
||||||
sed -i 's/piholeDNS2/PIHOLE_DNS_2/g' ${setupVars}
|
sed -i 's/piholeDNS2/PIHOLE_DNS_2/g' ${setupVars}
|
||||||
|
|
||||||
@ -1003,6 +947,7 @@ configureSelinux() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
displayFinalMessage() {
|
displayFinalMessage() {
|
||||||
|
if (( ${#1} > 0 )) ; then
|
||||||
# Final completion message to user
|
# Final completion message to user
|
||||||
whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using:
|
whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using:
|
||||||
|
|
||||||
@ -1011,8 +956,20 @@ IPv6: ${IPV6_ADDRESS}
|
|||||||
|
|
||||||
If you set a new IP address, you should restart the Pi.
|
If you set a new IP address, you should restart the Pi.
|
||||||
|
|
||||||
|
The install log is in /etc/pihole.
|
||||||
|
View the web interface at http://pi.hole/admin or http://${IPV4_ADDRESS%/*}/admin
|
||||||
|
The currently set password is ${1}" ${r} ${c}
|
||||||
|
else
|
||||||
|
whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using:
|
||||||
|
|
||||||
|
IPv4: ${IPV4_ADDRESS%/*}
|
||||||
|
IPv6: ${IPV6_ADDRESS}
|
||||||
|
|
||||||
|
If you set a new IP address, you should restart the Pi.
|
||||||
|
|
||||||
The install log is in /etc/pihole.
|
The install log is in /etc/pihole.
|
||||||
View the web interface at http://pi.hole/admin or http://${IPV4_ADDRESS%/*}/admin" ${r} ${c}
|
View the web interface at http://pi.hole/admin or http://${IPV4_ADDRESS%/*}/admin" ${r} ${c}
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
update_dialogs() {
|
update_dialogs() {
|
||||||
@ -1048,7 +1005,6 @@ update_dialogs() {
|
|||||||
echo "::: Cancel selected. Exiting..."
|
echo "::: Cancel selected. Exiting..."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
@ -1100,8 +1056,6 @@ main() {
|
|||||||
welcomeDialogs
|
welcomeDialogs
|
||||||
# Create directory for Pi-hole storage
|
# Create directory for Pi-hole storage
|
||||||
mkdir -p /etc/pihole/
|
mkdir -p /etc/pihole/
|
||||||
# Remove legacy scripts from previous storage location
|
|
||||||
remove_legacy_scripts
|
|
||||||
# Stop resolver and webserver while installing proceses
|
# Stop resolver and webserver while installing proceses
|
||||||
stop_service dnsmasq
|
stop_service dnsmasq
|
||||||
stop_service lighttpd
|
stop_service lighttpd
|
||||||
@ -1131,8 +1085,15 @@ main() {
|
|||||||
# Move the log file into /etc/pihole for storage
|
# Move the log file into /etc/pihole for storage
|
||||||
mv ${tmpLog} ${instalLogLoc}
|
mv ${tmpLog} ${instalLogLoc}
|
||||||
|
|
||||||
|
# Add password to web UI if there is none
|
||||||
|
pw=""
|
||||||
|
if [[ $(grep 'WEBPASSWORD' -c /etc/pihole/setupVars.conf) == 0 ]] ; then
|
||||||
|
pw=$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c 8)
|
||||||
|
pihole -a -p ${pw}
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "${useUpdateVars}" == false ]]; then
|
if [[ "${useUpdateVars}" == false ]]; then
|
||||||
displayFinalMessage
|
displayFinalMessage ${pw}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::: Restarting services..."
|
echo "::: Restarting services..."
|
||||||
@ -1155,6 +1116,16 @@ main() {
|
|||||||
echo "::: Update complete!"
|
echo "::: Update complete!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if (( ${#pw} > 0 )) ; then
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Note: As security measure a password has been installed for your web interface"
|
||||||
|
echo "::: The currently set password is"
|
||||||
|
echo "::: ${pw}"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: You can always change it using"
|
||||||
|
echo "::: pihole -a -p new_password"
|
||||||
|
fi
|
||||||
|
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: The install log is located at: /etc/pihole/install.log"
|
echo "::: The install log is located at: /etc/pihole/install.log"
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ removeNoPurge() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::: Removing config files and scripts..."
|
echo "::: Removing config files and scripts..."
|
||||||
package_check ${i} > /dev/null
|
package_check lighttpd > /dev/null
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
${SUDO} rm -rf /etc/lighttpd/ &> /dev/null
|
${SUDO} rm -rf /etc/lighttpd/ &> /dev/null
|
||||||
else
|
else
|
||||||
|
13
gravity.sh
13
gravity.sh
@ -45,11 +45,13 @@ fi
|
|||||||
|
|
||||||
#Remove the /* from the end of the IPv4addr.
|
#Remove the /* from the end of the IPv4addr.
|
||||||
IPV4_ADDRESS=${IPV4_ADDRESS%/*}
|
IPV4_ADDRESS=${IPV4_ADDRESS%/*}
|
||||||
|
IPV6_ADDRESS=${IPV6_ADDRESS}
|
||||||
|
|
||||||
# Variables for various stages of downloading and formatting the list
|
# Variables for various stages of downloading and formatting the list
|
||||||
basename=pihole
|
basename=pihole
|
||||||
piholeDir=/etc/${basename}
|
piholeDir=/etc/${basename}
|
||||||
adList=${piholeDir}/gravity.list
|
adList=${piholeDir}/gravity.list
|
||||||
|
localList=${piholeDir}/local.list
|
||||||
justDomainsExtension=domains
|
justDomainsExtension=domains
|
||||||
matterAndLight=${basename}.0.matterandlight.txt
|
matterAndLight=${basename}.0.matterandlight.txt
|
||||||
supernova=${basename}.1.supernova.txt
|
supernova=${basename}.1.supernova.txt
|
||||||
@ -241,19 +243,30 @@ gravity_unique() {
|
|||||||
gravity_hostFormat() {
|
gravity_hostFormat() {
|
||||||
# Format domain list as "192.168.x.x domain.com"
|
# Format domain list as "192.168.x.x domain.com"
|
||||||
echo -n "::: Formatting domains into a HOSTS file..."
|
echo -n "::: Formatting domains into a HOSTS file..."
|
||||||
|
|
||||||
|
if [[ -f /etc/hostname ]]; then
|
||||||
|
hostname=$(</etc/hostname)
|
||||||
|
elif [ -x "$(command -v hostname)" ]; then
|
||||||
|
hostname=$(hostname -f)
|
||||||
|
else
|
||||||
|
echo "::: Error: Unable to determine fully qualified domain name of host"
|
||||||
|
fi
|
||||||
# Check vars from setupVars.conf to see if we're using IPv4, IPv6, Or both.
|
# Check vars from setupVars.conf to see if we're using IPv4, IPv6, Or both.
|
||||||
if [[ -n "${IPV4_ADDRESS}" && -n "${IPV6_ADDRESS}" ]];then
|
if [[ -n "${IPV4_ADDRESS}" && -n "${IPV6_ADDRESS}" ]];then
|
||||||
|
|
||||||
|
echo -e "${IPV4_ADDRESS} ${hostname}\n${IPV6_ADDRESS} ${hostname}\n${IPV4_ADDRESS} pi.hole\n${IPV6_ADDRESS} pi.hole" > ${localList}
|
||||||
# Both IPv4 and IPv6
|
# Both IPv4 and IPv6
|
||||||
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPV4_ADDRESS" -v ipv6addr="$IPV6_ADDRESS" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPV4_ADDRESS" -v ipv6addr="$IPV6_ADDRESS" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||||
|
|
||||||
elif [[ -n "${IPV4_ADDRESS}" && -z "${IPV6_ADDRESS}" ]];then
|
elif [[ -n "${IPV4_ADDRESS}" && -z "${IPV6_ADDRESS}" ]];then
|
||||||
|
|
||||||
|
echo -e "${IPV4_ADDRESS} ${hostname}\n${IPV4_ADDRESS} pi.hole" > ${localList}
|
||||||
# Only IPv4
|
# Only IPv4
|
||||||
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPV4_ADDRESS" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPV4_ADDRESS" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||||
|
|
||||||
elif [[ -z "${IPV4_ADDRESS}" && -n "${IPV6_ADDRESS}" ]];then
|
elif [[ -z "${IPV4_ADDRESS}" && -n "${IPV6_ADDRESS}" ]];then
|
||||||
|
|
||||||
|
echo -e "${IPV6_ADDRESS} ${hostname}\n${IPV6_ADDRESS} pi.hole" > ${localList}
|
||||||
# Only IPv6
|
# Only IPv6
|
||||||
cat ${piholeDir}/${eventHorizon} | awk -v ipv6addr="$IPV6_ADDRESS" '{sub(/\r$/,""); print ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv6addr="$IPV6_ADDRESS" '{sub(/\r$/,""); print ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||||
|
|
||||||
|
32
pihole
32
pihole
@ -67,13 +67,28 @@ setupLCDFunction() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scanList(){
|
||||||
|
domain="${1}"
|
||||||
|
list="${2}"
|
||||||
|
method="${3}"
|
||||||
|
if [[ ${method} == "-exact" ]] ; then
|
||||||
|
grep -E "(^|\s)${domain}($|\s)" "${list}"
|
||||||
|
else
|
||||||
|
grep "${domain}" "${list}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
queryFunc() {
|
queryFunc() {
|
||||||
domain="${2}"
|
domain="${2}"
|
||||||
for list in /etc/pihole/list.*; do
|
method="${3}"
|
||||||
count=$(grep ${domain} $list | wc -l)
|
lists=( /etc/pihole/list.* /etc/pihole/blacklist.txt)
|
||||||
|
for list in ${lists[@]}; do
|
||||||
|
result=$(scanList ${domain} ${list} ${method})
|
||||||
|
# Remove empty lines before couting number of results
|
||||||
|
count=$(sed '/^\s*$/d' <<< "$result" | wc -l)
|
||||||
echo "::: ${list} (${count} results)"
|
echo "::: ${list} (${count} results)"
|
||||||
if [[ ${count} > 0 ]]; then
|
if [[ ${count} > 0 ]]; then
|
||||||
grep ${domain} ${list}
|
echo "${result}"
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
@ -120,7 +135,7 @@ restartDNS() {
|
|||||||
piholeEnable() {
|
piholeEnable() {
|
||||||
if [[ "${1}" == "0" ]] ; then
|
if [[ "${1}" == "0" ]] ; then
|
||||||
#Disable Pihole
|
#Disable Pihole
|
||||||
sed -i 's/^addn-hosts/#addn-hosts/' /etc/dnsmasq.d/01-pihole.conf
|
sed -i 's/^addn-hosts=\/etc\/pihole\/gravity.list/#addn-hosts=\/etc\/pihole\/gravity.list/' /etc/dnsmasq.d/01-pihole.conf
|
||||||
echo "::: Blocking has been disabled!"
|
echo "::: Blocking has been disabled!"
|
||||||
if [[ $# > 1 ]] ; then
|
if [[ $# > 1 ]] ; then
|
||||||
if [[ ${2} == *"s"* ]] ; then
|
if [[ ${2} == *"s"* ]] ; then
|
||||||
@ -197,6 +212,11 @@ piholeStatus() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tailFunc() {
|
||||||
|
echo "Press Ctrl-C to exit"
|
||||||
|
tail -F /var/log/pihole.log
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
helpFunc() {
|
helpFunc() {
|
||||||
cat << EOM
|
cat << EOM
|
||||||
@ -210,13 +230,16 @@ helpFunc() {
|
|||||||
::: -b, blacklist Blacklist domains
|
::: -b, blacklist Blacklist domains
|
||||||
::: -d, debug Start a debugging session if having trouble
|
::: -d, debug Start a debugging session if having trouble
|
||||||
::: -f, flush Flush the pihole.log file
|
::: -f, flush Flush the pihole.log file
|
||||||
|
::: -t, tail Output the last lines of the pihole.log file. Lines are appended as the file grows
|
||||||
::: -up, updatePihole Update Pi-hole
|
::: -up, updatePihole Update Pi-hole
|
||||||
|
::: -r, reconfigure Reconfigure or Repair Pi-hole
|
||||||
::: -g, updateGravity Update the list of ad-serving domains
|
::: -g, updateGravity Update the list of ad-serving domains
|
||||||
::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it
|
::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it
|
||||||
::: -c, chronometer Calculates stats and displays to an LCD
|
::: -c, chronometer Calculates stats and displays to an LCD
|
||||||
::: -h, help Show this help dialog
|
::: -h, help Show this help dialog
|
||||||
::: -v, version Show current versions
|
::: -v, version Show current versions
|
||||||
::: -q, query Query the adlists for a specific domain
|
::: -q, query Query the adlists for a specific domain
|
||||||
|
::: Use pihole -q domain -exact if you want to see exact matches only
|
||||||
::: -l, logging Enable or Disable logging (pass 'on' or 'off')
|
::: -l, logging Enable or Disable logging (pass 'on' or 'off')
|
||||||
::: -a, admin Admin webpage options
|
::: -a, admin Admin webpage options
|
||||||
::: uninstall Uninstall Pi-Hole from your system :(!
|
::: uninstall Uninstall Pi-Hole from your system :(!
|
||||||
@ -255,5 +278,6 @@ case "${1}" in
|
|||||||
"status" ) piholeStatus "$2";;
|
"status" ) piholeStatus "$2";;
|
||||||
"restartdns" ) restartDNS;;
|
"restartdns" ) restartDNS;;
|
||||||
"-a" | "admin" ) webpageFunc "$@";;
|
"-a" | "admin" ) webpageFunc "$@";;
|
||||||
|
"-t" | "tail" ) tailFunc;;
|
||||||
* ) helpFunc;;
|
* ) helpFunc;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user