Skip to content

Commit fbee18e

Browse files
author
Jacob Salmela
authored
Merge pull request pi-hole#2056 from pi-hole/release/v3.3.1
Pi-hole core v3.3.1
2 parents 1e87850 + d31a498 commit fbee18e

File tree

8 files changed

+95
-95
lines changed

8 files changed

+95
-95
lines changed

.pullapprove.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

advanced/Scripts/list.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
# Globals
1212
basename=pihole
13-
piholeDir=/etc/${basename}
14-
whitelist=${piholeDir}/whitelist.txt
15-
blacklist=${piholeDir}/blacklist.txt
13+
piholeDir=/etc/"${basename}"
14+
whitelist="${piholeDir}"/whitelist.txt
15+
blacklist="${piholeDir}"/blacklist.txt
1616
readonly wildcardlist="/etc/dnsmasq.d/03-pihole-wildcard.conf"
1717
reload=false
1818
addmode=true
@@ -80,8 +80,13 @@ HandleOther() {
8080

8181
PoplistFile() {
8282
# Check whitelist file exists, and if not, create it
83-
if [[ ! -f ${whitelist} ]]; then
84-
touch ${whitelist}
83+
if [[ ! -f "${whitelist}" ]]; then
84+
touch "${whitelist}"
85+
fi
86+
87+
# Check blacklist file exists, and if not, create it
88+
if [[ ! -f "${blacklist}" ]]; then
89+
touch "${blacklist}"
8590
fi
8691

8792
for dom in "${domList[@]}"; do

advanced/Scripts/piholeCheckout.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ checkout() {
256256
get_binary_name
257257
local path
258258
path="development/${binary}"
259+
echo "development" > /etc/pihole/ftlbranch
259260
FTLinstall "${binary}" "${path}"
260261
elif [[ "${1}" == "master" ]] ; then
261262
# Shortcut to check out master branches
@@ -270,6 +271,7 @@ checkout() {
270271
get_binary_name
271272
local path
272273
path="master/${binary}"
274+
echo "master" > /etc/pihole/ftlbranch
273275
FTLinstall "${binary}" "${path}"
274276
elif [[ "${1}" == "core" ]] ; then
275277
str="Fetching branches from ${piholeGitUrl}"
@@ -332,6 +334,7 @@ checkout() {
332334

333335
if check_download_exists "$path"; then
334336
echo " ${TICK} Branch ${2} exists"
337+
echo "${2}" > /etc/pihole/ftlbranch
335338
FTLinstall "${binary}" "${path}"
336339
else
337340
echo " ${CROSS} Requested branch \"${2}\" is not available"

advanced/Scripts/piholeLogFlush.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@
1111
colfile="/opt/pihole/COL_TABLE"
1212
source ${colfile}
1313

14+
# Determine database location
15+
# Obtain DBFILE=... setting from pihole-FTL.db
16+
# Constructed to return nothing when
17+
# a) the setting is not present in the config file, or
18+
# b) the setting is commented out (e.g. "#DBFILE=...")
19+
DBFILE="$(sed -n -e 's/^\s^.DBFILE\s*=\s*//p' /etc/pihole/pihole-FTL.conf)"
20+
# Test for empty string. Use standard path in this case.
21+
if [ -z "$DBFILE" ]; then
22+
DBFILE="/etc/pihole/pihole-FTL.db"
23+
fi
24+
1425
if [[ "$@" != *"quiet"* ]]; then
1526
echo -ne " ${INFO} Flushing /var/log/pihole.log ..."
1627
fi
@@ -41,8 +52,12 @@ else
4152
echo " " > /var/log/pihole.log.1
4253
fi
4354
fi
55+
# Delete most recent 24 hours from FTL's database, leave even older data intact (don't wipe out all history)
56+
deleted=$(sqlite3 "${DBFILE}" "DELETE FROM queries WHERE timestamp >= strftime('%s','now')-86400; select changes() from queries limit 1")
57+
4458
fi
4559

4660
if [[ "$@" != *"quiet"* ]]; then
4761
echo -e "${OVER} ${TICK} Flushed /var/log/pihole.log"
62+
echo -e " ${TICK} Deleted ${deleted} queries from database"
4863
fi

advanced/Scripts/webpage.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC68345710423
182182

183183
add_dnsmasq_setting "interface" "${PIHOLE_INTERFACE}"
184184
fi
185+
if [[ "${CONDITIONAL_FORWARDING}" == true ]]; then
186+
add_dnsmasq_setting "server=/${CONDITIONAL_FORWARDING_DOMAIN}/${CONDITIONAL_FORWARDING_IP}"
187+
add_dnsmasq_setting "server=/${CONDITIONAL_FORWARDING_REVERSE}/${CONDITIONAL_FORWARDING_IP}"
188+
fi
185189

186190
}
187191

@@ -211,6 +215,17 @@ SetDNSServers() {
211215
else
212216
change_setting "DNSSEC" "false"
213217
fi
218+
if [[ "${args[6]}" == "conditional_forwarding" ]]; then
219+
change_setting "CONDITIONAL_FORWARDING" "true"
220+
change_setting "CONDITIONAL_FORWARDING_IP" "${args[7]}"
221+
change_setting "CONDITIONAL_FORWARDING_DOMAIN" "${args[8]}"
222+
change_setting "CONDITIONAL_FORWARDING_REVERSE" "${args[9]}"
223+
else
224+
change_setting "CONDITIONAL_FORWARDING" "false"
225+
delete_setting "CONDITIONAL_FORWARDING_IP"
226+
delete_setting "CONDITIONAL_FORWARDING_DOMAIN"
227+
delete_setting "CONDITIONAL_FORWARDING_REVERSE"
228+
fi
214229

215230
ProcessDNSSettings
216231

advanced/index.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ function setHeader($type = "x") {
9898

9999
/* Start processing Block Page from here */
100100

101-
// Determine placeholder text based off $svPasswd presence
102-
$wlPlaceHolder = empty($svPasswd) ? "No admin password set" : "Javascript disabled";
103-
104101
// Define admin email address text based off $svEmail presence
105102
$bpAskAdmin = !empty($svEmail) ? '<a href="mailto:'.$svEmail.'?subject=Site Blocked: '.$serverName.'"></a>' : "<span/>";
106103

@@ -236,11 +233,21 @@ function queryAds($serverName) {
236233
window.onload = function () {
237234
<?php
238235
// Remove href fallback from "Back to safety" button
239-
if ($featuredTotal > 0) echo '$("#bpBack").removeAttr("href");';
240-
// Enable whitelisting if $svPasswd is present & JS is available
241-
if (!empty($svPasswd) && $featuredTotal > 0) {
242-
echo '$("#bpWLPassword, #bpWhitelist").prop("disabled", false);';
236+
if ($featuredTotal > 0) {
237+
echo '$("#bpBack").removeAttr("href");';
238+
239+
// Enable whitelisting if JS is available
240+
echo '$("#bpWhitelist").prop("disabled", false);';
241+
242+
// Enable password input if necessary
243+
if (!empty($svPasswd)) {
243244
echo '$("#bpWLPassword").attr("placeholder", "Password");';
245+
echo '$("#bpWLPassword").prop("disabled", false);';
246+
}
247+
// Otherwise hide the input
248+
else {
249+
echo '$("#bpWLPassword").hide();';
250+
}
244251
}
245252
?>
246253
}
@@ -294,7 +301,7 @@ function queryAds($serverName) {
294301

295302
<form id="bpWLButtons" class="buttons">
296303
<input id="bpWLDomain" type="text" value="<?=$serverName ?>" disabled/>
297-
<input id="bpWLPassword" type="password" placeholder="<?=$wlPlaceHolder ?>" disabled/><button id="bpWhitelist" type="button" disabled></button>
304+
<input id="bpWLPassword" type="password" placeholder="Javascript disabled" disabled/><button id="bpWhitelist" type="button" disabled></button>
298305
</form>
299306
</div>
300307
</main>

automated install/basic-install.sh

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ set -e
2323

2424
######## VARIABLES #########
2525
# For better maintainability, we store as much information that can change in variables
26-
# This allows us to make a change in one place that can propogate to all instances of the variable
26+
# This allows us to make a change in one place that can propagate to all instances of the variable
2727
# These variables should all be GLOBAL variables, written in CAPS
2828
# Local variables will be in lowercase and will exist only within functions
2929
# It's still a work in progress, so you may see some variance in this guideline until it is complete
@@ -43,7 +43,7 @@ webInterfaceGitUrl="https://github.com/pi-hole/AdminLTE.git"
4343
webInterfaceDir="/var/www/html/admin"
4444
piholeGitUrl="https://github.com/pi-hole/pi-hole.git"
4545
PI_HOLE_LOCAL_REPO="/etc/.pihole"
46-
# These are the names of piholes files, stored in an array
46+
# These are the names of pi-holes files, stored in an array
4747
PI_HOLE_FILES=(chronometer list piholeDebug piholeLogFlush setupLCD update version gravity uninstall webpage)
4848
# This folder is where the Pi-hole scripts will be installed
4949
PI_HOLE_INSTALL_DIR="/opt/pihole"
@@ -81,7 +81,7 @@ runUnattended=false
8181
if [[ -f "${coltable}" ]]; then
8282
# source it
8383
source ${coltable}
84-
# Othwerise,
84+
# Otherwise,
8585
else
8686
# Set these values so the installer can still run in color
8787
COL_NC='\e[0m' # No Color
@@ -163,7 +163,7 @@ if command -v apt-get &> /dev/null; then
163163
# These programs are stored in an array so they can be looped through later
164164
INSTALLER_DEPS=(apt-utils dialog debconf dhcpcd5 git ${iproute_pkg} whiptail)
165165
# Pi-hole itself has several dependencies that also need to be installed
166-
PIHOLE_DEPS=(bc cron curl dnsmasq dnsutils iputils-ping lsof netcat sudo unzip wget idn2)
166+
PIHOLE_DEPS=(bc cron curl dnsmasq dnsutils iputils-ping lsof netcat sudo unzip wget idn2 sqlite3)
167167
# The Web dashboard has some that also need to be installed
168168
# It's useful to separate the two since our repos are also setup as "Core" code and "Web" code
169169
PIHOLE_WEB_DEPS=(lighttpd ${phpVer}-common ${phpVer}-cgi ${phpVer}-${phpSqlite})
@@ -771,6 +771,7 @@ setDNS() {
771771
Comodo ""
772772
DNSWatch ""
773773
Quad9 ""
774+
FamilyShield ""
774775
Custom "")
775776
# In a whiptail dialog, show the options
776777
DNSchoices=$(whiptail --separate-output --menu "Select Upstream DNS Provider. To use your own, select Custom." ${r} ${c} 7 \
@@ -817,6 +818,11 @@ setDNS() {
817818
PIHOLE_DNS_1="9.9.9.9"
818819
PIHOLE_DNS_2="149.112.112.112"
819820
;;
821+
FamilyShield)
822+
echo "FamilyShield servers"
823+
PIHOLE_DNS_1="208.67.222.123"
824+
PIHOLE_DNS_2="208.67.220.123"
825+
;;
820826
Custom)
821827
# Until the DNS settings are selected,
822828
until [[ "${DNSSettingsCorrect}" = True ]]; do
@@ -918,7 +924,7 @@ setLogging() {
918924
esac
919925
}
920926

921-
# Funtion to ask the user if they want to install the dashboard
927+
# Function to ask the user if they want to install the dashboard
922928
setAdminFlag() {
923929
# Local, named variables
924930
local WebToggleCommand
@@ -946,7 +952,7 @@ setAdminFlag() {
946952
esac
947953
}
948954

949-
# Check if /etc/dnsmasq.conf is from pihole. If so replace with an original and install new in .d directory
955+
# Check if /etc/dnsmasq.conf is from pi-hole. If so replace with an original and install new in .d directory
950956
version_check_dnsmasq() {
951957
# Local, named variables
952958
local dnsmasq_conf="/etc/dnsmasq.conf"
@@ -1734,17 +1740,14 @@ clone_or_update_repos() {
17341740
fi
17351741
}
17361742

1737-
# Download and install FTL binary
1743+
# Download FTL binary to random temp directory and install FTL binary
17381744
FTLinstall() {
17391745
# Local, named variables
17401746
local binary="${1}"
17411747
local latesttag
1742-
local orig_dir
17431748
local str="Downloading and Installing FTL"
17441749
echo -ne " ${INFO} ${str}..."
17451750

1746-
# Get the current working directory
1747-
orig_dir="${PWD}"
17481751
# Find the latest version tag for FTL
17491752
latesttag=$(curl -sI https://github.com/pi-hole/FTL/releases/latest | grep "Location" | awk -F '/' '{print $NF}')
17501753
# Tags should always start with v, check for that.
@@ -1754,42 +1757,44 @@ FTLinstall() {
17541757
return 1
17551758
fi
17561759

1760+
# Move into the temp ftl directory
1761+
pushd "$(mktemp -d)" || { echo "Unable to make temporary directory for FTL binary download"; return 1; }
1762+
1763+
# Always replace pihole-FTL.service
1764+
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/pihole-FTL.service" "/etc/init.d/pihole-FTL"
1765+
17571766
# If the download worked,
1758-
if curl -sSL --fail "https://github.com/pi-hole/FTL/releases/download/${latesttag%$'\r'}/${binary}" -o "/tmp/${binary}"; then
1767+
if curl -sSL --fail "https://github.com/pi-hole/FTL/releases/download/${latesttag%$'\r'}/${binary}" -o "${binary}"; then
17591768
# get sha1 of the binary we just downloaded for verification.
1760-
curl -sSL --fail "https://github.com/pi-hole/FTL/releases/download/${latesttag%$'\r'}/${binary}.sha1" -o "/tmp/${binary}.sha1"
1769+
curl -sSL --fail "https://github.com/pi-hole/FTL/releases/download/${latesttag%$'\r'}/${binary}.sha1" -o "${binary}.sha1"
17611770

1762-
# Move into the temp directory
1763-
cd /tmp
17641771
# If we downloaded binary file (as opposed to text),
17651772
if sha1sum --status --quiet -c "${binary}".sha1; then
17661773
echo -n "transferred... "
17671774
# Stop FTL
17681775
stop_service pihole-FTL &> /dev/null
17691776
# Install the new version with the correct permissions
1770-
install -T -m 0755 /tmp/${binary} /usr/bin/pihole-FTL
1771-
# Remove the tempoary file
1772-
rm /tmp/${binary} /tmp/${binary}.sha1
1777+
install -T -m 0755 "${binary}" /usr/bin/pihole-FTL
17731778
# Move back into the original directory the user was in
1774-
cd "${orig_dir}"
1779+
popd || { echo "Unable to return to original directory after FTL binary download."; return 1; }
17751780
# Install the FTL service
1776-
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/pihole-FTL.service" "/etc/init.d/pihole-FTL"
17771781
echo -e "${OVER} ${TICK} ${str}"
17781782
return 0
17791783
# Otherise,
17801784
else
1785+
# the download failed, so just go back to the original directory
1786+
popd || { echo "Unable to return to original directory after FTL binary download."; return 1; }
17811787
echo -e "${OVER} ${CROSS} ${str}"
17821788
echo -e " ${COL_LIGHT_RED}Error: Download of binary from Github failed${COL_NC}"
1783-
# the download failed, so just go back to the original directory
1784-
cd "${orig_dir}"
17851789
return 1
17861790
fi
17871791
# Otherwise,
17881792
else
1789-
cd "${orig_dir}"
1793+
popd || { echo "Unable to return to original directory after FTL binary download."; return 1; }
17901794
echo -e "${OVER} ${CROSS} ${str}"
17911795
# The URL could not be found
17921796
echo -e " ${COL_LIGHT_RED}Error: URL not found${COL_NC}"
1797+
return 1
17931798
fi
17941799
}
17951800

@@ -1957,7 +1962,7 @@ main() {
19571962
for var in "$@"; do
19581963
case "$var" in
19591964
"--reconfigure" ) reconfigure=true;;
1960-
"--i_do_not_follow_recommendations" ) skipSpaceCheck=false;;
1965+
"--i_do_not_follow_recommendations" ) skipSpaceCheck=true;;
19611966
"--unattended" ) runUnattended=true;;
19621967
esac
19631968
done

0 commit comments

Comments
 (0)