Compare commits
15 Commits
v4.2
...
new/native
Author | SHA1 | Date | |
---|---|---|---|
|
f45118ce2e | ||
|
2cf092ec44 | ||
|
7c9e1392ad | ||
|
1e284f69ea | ||
|
516ed83638 | ||
|
f7ca74cf1d | ||
|
ebba32e1c4 | ||
|
7d2507527a | ||
|
97decb3a73 | ||
|
f360959efc | ||
|
365b547545 | ||
|
12b51d94cd | ||
|
810bc1774f | ||
|
c6f4c47e69 | ||
|
1463625812 |
@@ -167,7 +167,7 @@ checkout() {
|
||||
echo " ${TICK} Branch ${2} exists"
|
||||
echo "${2}" > /etc/pihole/ftlbranch
|
||||
FTLinstall "${binary}"
|
||||
restart_service pihole-FTL
|
||||
start_service pihole-FTL
|
||||
enable_service pihole-FTL
|
||||
else
|
||||
echo " ${CROSS} Requested branch \"${2}\" is not available"
|
||||
|
@@ -76,7 +76,7 @@ WEB_SERVER_CONFIG_DIRECTORY="/etc/lighttpd"
|
||||
HTML_DIRECTORY="/var/www/html"
|
||||
WEB_GIT_DIRECTORY="${HTML_DIRECTORY}/admin"
|
||||
#BLOCK_PAGE_DIRECTORY="${HTML_DIRECTORY}/pihole"
|
||||
SHM_DIRECTORY="/dev/shm"
|
||||
SHM_DIRECTORY="/var/run/shm"
|
||||
|
||||
# Files required by Pi-hole
|
||||
# https://discourse.pi-hole.net/t/what-files-does-pi-hole-use/1684
|
||||
|
@@ -41,7 +41,7 @@ start() {
|
||||
chmod 0644 /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole.log
|
||||
echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo.piholeFTL
|
||||
if setcap CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_NET_ADMIN+eip "$(which pihole-FTL)"; then
|
||||
su -s /bin/sh -c "/usr/bin/pihole-FTL" "$FTLUSER"
|
||||
runuser -u "$FTLUSER" "/usr/bin/pihole-FTL"
|
||||
else
|
||||
echo "Warning: Starting pihole-FTL as root because setting capabilities is not supported on this system"
|
||||
pihole-FTL
|
46
advanced/Templates/systemd/pihole-FTL.service
Normal file
46
advanced/Templates/systemd/pihole-FTL.service
Normal file
@@ -0,0 +1,46 @@
|
||||
[Unit]
|
||||
Description=Pi-hole FTLDNS
|
||||
; This unit is supposed to indicate when network functionality is available, but it is only
|
||||
; very weakly defined what that is supposed to mean, with one exception: at shutdown, a unit
|
||||
; that is ordered after network.target will be stopped before the network
|
||||
After=network.target
|
||||
; A target that should be used as synchronization point for all host/network name service lookups.
|
||||
; All services for which the availability of full host/network name resolution is essential should
|
||||
; be ordered after this target, but not pull it in.
|
||||
Wants=nss-lookup.target
|
||||
Before=nss-lookup.target
|
||||
|
||||
[Service]
|
||||
Restart=on-abnormal
|
||||
User=pihole
|
||||
Group=pihole
|
||||
PermissionsStartOnly=true
|
||||
|
||||
Type=forking
|
||||
PIDFile=/run/pihole-FTL.pid
|
||||
|
||||
ExecStartPre=/bin/touch /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole.log /etc/pihole/dhcp.leases
|
||||
ExecStartPre=/bin/chown pihole:pihole /etc/pihole /etc/pihole/dhcp.leases
|
||||
ExecStartPre=/bin/mkdir -p /var/run/pihole /var/log/pihole
|
||||
ExecStartPre=/bin/chown pihole:pihole /var/run/pihole /var/log/pihole
|
||||
ExecStartPre=-/bin/rm /var/run/pihole/FTL.sock
|
||||
ExecStartPre=/bin/chown pihole:pihole /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole.log
|
||||
ExecStartPre=/bin/chmod 0644 /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole.log
|
||||
ExecStartPre=/bin/echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo.piholeFTL
|
||||
|
||||
ExecStart=/usr/bin/pihole-FTL
|
||||
RestartSec=30s
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
|
||||
; Use graceful shutdown with a reasonable timeout
|
||||
TimeoutStopSec=10s
|
||||
|
||||
; Make /usr, /boot, /etc and possibly some more folders read-only...
|
||||
ProtectSystem=full
|
||||
; ... except /etc/pihole
|
||||
; This merely retains r/w access rights, it does not add any new.
|
||||
; Must still be writable on the host!
|
||||
ReadWriteDirectories=/etc/pihole
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@@ -28,6 +28,20 @@ set -e
|
||||
# Local variables will be in lowercase and will exist only within functions
|
||||
# It's still a work in progress, so you may see some variance in this guideline until it is complete
|
||||
|
||||
# List of supported DNS servers
|
||||
DNS_SERVERS=$(cat << EOM
|
||||
Google (ECS);8.8.8.8;8.8.4.4;2001:4860:4860:0:0:0:0:8888;2001:4860:4860:0:0:0:0:8844
|
||||
OpenDNS (ECS);208.67.222.222;208.67.220.220;2620:0:ccc::2;2620:0:ccd::2
|
||||
Level3;4.2.2.1;4.2.2.2;;
|
||||
Comodo;8.26.56.26;8.20.247.20;;
|
||||
DNS.WATCH;84.200.69.80;84.200.70.40;2001:1608:10:25:0:0:1c04:b12f;2001:1608:10:25:0:0:9249:d69b
|
||||
Quad9 (filtered, DNSSEC);9.9.9.9;149.112.112.112;2620:fe::fe;2620:fe::9
|
||||
Quad9 (unfiltered, no DNSSEC);9.9.9.10;149.112.112.10;2620:fe::10;2620:fe::fe:10
|
||||
Quad9 (filtered + ECS);9.9.9.11;149.112.112.11;2620:fe::11;
|
||||
Cloudflare;1.1.1.1;1.0.0.1;2606:4700:4700::1111;2606:4700:4700::1001
|
||||
EOM
|
||||
)
|
||||
|
||||
# Location for final installation log storage
|
||||
installLogLoc=/etc/pihole/install.log
|
||||
# This is an important file as it contains information specific to the machine it's being installed on
|
||||
@@ -115,9 +129,6 @@ else
|
||||
OVER="\\r\\033[K"
|
||||
fi
|
||||
|
||||
# Define global binary variable
|
||||
binary="tbd"
|
||||
|
||||
# A simple function that just echoes out our logo in ASCII format
|
||||
# This lets users know that it is a Pi-hole, LLC product
|
||||
show_ascii_berry() {
|
||||
@@ -919,15 +930,26 @@ setDNS() {
|
||||
local DNSSettingsCorrect
|
||||
|
||||
# In an array, list the available upstream providers
|
||||
DNSChooseOptions=(Google ""
|
||||
OpenDNS ""
|
||||
Level3 ""
|
||||
Comodo ""
|
||||
DNSWatch ""
|
||||
Quad9 ""
|
||||
FamilyShield ""
|
||||
Cloudflare ""
|
||||
Custom "")
|
||||
DNSChooseOptions=()
|
||||
local DNSServerCount=0
|
||||
# Save the old Internal Field Separator in a variable
|
||||
OIFS=$IFS
|
||||
# and set the new one to newline
|
||||
IFS=$'\n'
|
||||
# Put the DNS Servers into an array
|
||||
for DNSServer in ${DNS_SERVERS}
|
||||
do
|
||||
DNSName="$(cut -d';' -f1 <<< "${DNSServer}")"
|
||||
DNSChooseOptions[DNSServerCount]="${DNSName}"
|
||||
(( DNSServerCount=DNSServerCount+1 ))
|
||||
DNSChooseOptions[DNSServerCount]=""
|
||||
(( DNSServerCount=DNSServerCount+1 ))
|
||||
done
|
||||
DNSChooseOptions[DNSServerCount]="Custom"
|
||||
(( DNSServerCount=DNSServerCount+1 ))
|
||||
DNSChooseOptions[DNSServerCount]=""
|
||||
# Restore the IFS to what it was
|
||||
IFS=${OIFS}
|
||||
# In a whiptail dialog, show the options
|
||||
DNSchoices=$(whiptail --separate-output --menu "Select Upstream DNS Provider. To use your own, select Custom." ${r} ${c} 7 \
|
||||
"${DNSChooseOptions[@]}" 2>&1 >/dev/tty) || \
|
||||
@@ -937,113 +959,90 @@ setDNS() {
|
||||
# Display the selection
|
||||
printf " %b Using " "${INFO}"
|
||||
# Depending on the user's choice, set the GLOBAl variables to the IP of the respective provider
|
||||
case ${DNSchoices} in
|
||||
Google)
|
||||
printf "Google DNS servers\\n"
|
||||
PIHOLE_DNS_1="8.8.8.8"
|
||||
PIHOLE_DNS_2="8.8.4.4"
|
||||
;;
|
||||
OpenDNS)
|
||||
printf "OpenDNS servers\\n"
|
||||
PIHOLE_DNS_1="208.67.222.222"
|
||||
PIHOLE_DNS_2="208.67.220.220"
|
||||
;;
|
||||
Level3)
|
||||
printf "Level3 servers\\n"
|
||||
PIHOLE_DNS_1="4.2.2.1"
|
||||
PIHOLE_DNS_2="4.2.2.2"
|
||||
;;
|
||||
Comodo)
|
||||
printf "Comodo Secure servers\\n"
|
||||
PIHOLE_DNS_1="8.26.56.26"
|
||||
PIHOLE_DNS_2="8.20.247.20"
|
||||
;;
|
||||
DNSWatch)
|
||||
printf "DNS.WATCH servers\\n"
|
||||
PIHOLE_DNS_1="84.200.69.80"
|
||||
PIHOLE_DNS_2="84.200.70.40"
|
||||
;;
|
||||
Quad9)
|
||||
printf "Quad9 servers\\n"
|
||||
PIHOLE_DNS_1="9.9.9.9"
|
||||
PIHOLE_DNS_2="149.112.112.112"
|
||||
;;
|
||||
FamilyShield)
|
||||
printf "FamilyShield servers\\n"
|
||||
PIHOLE_DNS_1="208.67.222.123"
|
||||
PIHOLE_DNS_2="208.67.220.123"
|
||||
;;
|
||||
Cloudflare)
|
||||
printf "Cloudflare servers\\n"
|
||||
PIHOLE_DNS_1="1.1.1.1"
|
||||
PIHOLE_DNS_2="1.0.0.1"
|
||||
;;
|
||||
Custom)
|
||||
# Until the DNS settings are selected,
|
||||
until [[ "${DNSSettingsCorrect}" = True ]]; do
|
||||
#
|
||||
strInvalid="Invalid"
|
||||
# If the first
|
||||
if [[ ! "${PIHOLE_DNS_1}" ]]; then
|
||||
# and second upstream servers do not exist
|
||||
if [[ ! "${PIHOLE_DNS_2}" ]]; then
|
||||
prePopulate=""
|
||||
# Otherwise,
|
||||
else
|
||||
prePopulate=", ${PIHOLE_DNS_2}"
|
||||
fi
|
||||
elif [[ "${PIHOLE_DNS_1}" ]] && [[ ! "${PIHOLE_DNS_2}" ]]; then
|
||||
prePopulate="${PIHOLE_DNS_1}"
|
||||
elif [[ "${PIHOLE_DNS_1}" ]] && [[ "${PIHOLE_DNS_2}" ]]; then
|
||||
prePopulate="${PIHOLE_DNS_1}, ${PIHOLE_DNS_2}"
|
||||
fi
|
||||
|
||||
# Dialog for the user to enter custom upstream servers
|
||||
piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), separated by a comma.\\n\\nFor example '8.8.8.8, 8.8.4.4'" ${r} ${c} "${prePopulate}" 3>&1 1>&2 2>&3) || \
|
||||
{ printf " %bCancel was selected, exiting installer%b\\n" "${COL_LIGHT_RED}" "${COL_NC}"; exit 1; }
|
||||
# Clean user input and replace whitespace with comma.
|
||||
piholeDNS=$(sed 's/[, \t]\+/,/g' <<< "${piholeDNS}")
|
||||
|
||||
printf -v PIHOLE_DNS_1 "%s" "${piholeDNS%%,*}"
|
||||
printf -v PIHOLE_DNS_2 "%s" "${piholeDNS##*,}"
|
||||
|
||||
# If the IP is valid,
|
||||
if ! valid_ip "${PIHOLE_DNS_1}" || [[ ! "${PIHOLE_DNS_1}" ]]; then
|
||||
# store it in the variable so we can use it
|
||||
PIHOLE_DNS_1=${strInvalid}
|
||||
fi
|
||||
# Do the same for the secondary server
|
||||
if ! valid_ip "${PIHOLE_DNS_2}" && [[ "${PIHOLE_DNS_2}" ]]; then
|
||||
PIHOLE_DNS_2=${strInvalid}
|
||||
fi
|
||||
# If either of the DNS servers are invalid,
|
||||
if [[ "${PIHOLE_DNS_1}" == "${strInvalid}" ]] || [[ "${PIHOLE_DNS_2}" == "${strInvalid}" ]]; then
|
||||
# explain this to the user
|
||||
whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\\n\\n DNS Server 1: $PIHOLE_DNS_1\\n DNS Server 2: ${PIHOLE_DNS_2}" ${r} ${c}
|
||||
# and set the variables back to nothing
|
||||
if [[ "${PIHOLE_DNS_1}" == "${strInvalid}" ]]; then
|
||||
PIHOLE_DNS_1=""
|
||||
fi
|
||||
if [[ "${PIHOLE_DNS_2}" == "${strInvalid}" ]]; then
|
||||
PIHOLE_DNS_2=""
|
||||
fi
|
||||
# Since the settings will not work, stay in the loop
|
||||
DNSSettingsCorrect=False
|
||||
if [[ "${DNSchoices}" == "Custom" ]]
|
||||
then
|
||||
# Until the DNS settings are selected,
|
||||
until [[ "${DNSSettingsCorrect}" = True ]]; do
|
||||
#
|
||||
strInvalid="Invalid"
|
||||
# If the first
|
||||
if [[ ! "${PIHOLE_DNS_1}" ]]; then
|
||||
# and second upstream servers do not exist
|
||||
if [[ ! "${PIHOLE_DNS_2}" ]]; then
|
||||
prePopulate=""
|
||||
# Otherwise,
|
||||
else
|
||||
# Show the settings
|
||||
if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\\n DNS Server 1: $PIHOLE_DNS_1\\n DNS Server 2: ${PIHOLE_DNS_2}" ${r} ${c}); then
|
||||
# and break from the loop since the servers are valid
|
||||
DNSSettingsCorrect=True
|
||||
# Otherwise,
|
||||
else
|
||||
# If the settings are wrong, the loop continues
|
||||
DNSSettingsCorrect=False
|
||||
fi
|
||||
prePopulate=", ${PIHOLE_DNS_2}"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
esac
|
||||
elif [[ "${PIHOLE_DNS_1}" ]] && [[ ! "${PIHOLE_DNS_2}" ]]; then
|
||||
prePopulate="${PIHOLE_DNS_1}"
|
||||
elif [[ "${PIHOLE_DNS_1}" ]] && [[ "${PIHOLE_DNS_2}" ]]; then
|
||||
prePopulate="${PIHOLE_DNS_1}, ${PIHOLE_DNS_2}"
|
||||
fi
|
||||
|
||||
# Dialog for the user to enter custom upstream servers
|
||||
piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), separated by a comma.\\n\\nFor example '8.8.8.8, 8.8.4.4'" ${r} ${c} "${prePopulate}" 3>&1 1>&2 2>&3) || \
|
||||
{ printf " %bCancel was selected, exiting installer%b\\n" "${COL_LIGHT_RED}" "${COL_NC}"; exit 1; }
|
||||
# Clean user input and replace whitespace with comma.
|
||||
piholeDNS=$(sed 's/[, \t]\+/,/g' <<< "${piholeDNS}")
|
||||
|
||||
printf -v PIHOLE_DNS_1 "%s" "${piholeDNS%%,*}"
|
||||
printf -v PIHOLE_DNS_2 "%s" "${piholeDNS##*,}"
|
||||
|
||||
# If the IP is valid,
|
||||
if ! valid_ip "${PIHOLE_DNS_1}" || [[ ! "${PIHOLE_DNS_1}" ]]; then
|
||||
# store it in the variable so we can use it
|
||||
PIHOLE_DNS_1=${strInvalid}
|
||||
fi
|
||||
# Do the same for the secondary server
|
||||
if ! valid_ip "${PIHOLE_DNS_2}" && [[ "${PIHOLE_DNS_2}" ]]; then
|
||||
PIHOLE_DNS_2=${strInvalid}
|
||||
fi
|
||||
# If either of the DNS servers are invalid,
|
||||
if [[ "${PIHOLE_DNS_1}" == "${strInvalid}" ]] || [[ "${PIHOLE_DNS_2}" == "${strInvalid}" ]]; then
|
||||
# explain this to the user
|
||||
whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\\n\\n DNS Server 1: $PIHOLE_DNS_1\\n DNS Server 2: ${PIHOLE_DNS_2}" ${r} ${c}
|
||||
# and set the variables back to nothing
|
||||
if [[ "${PIHOLE_DNS_1}" == "${strInvalid}" ]]; then
|
||||
PIHOLE_DNS_1=""
|
||||
fi
|
||||
if [[ "${PIHOLE_DNS_2}" == "${strInvalid}" ]]; then
|
||||
PIHOLE_DNS_2=""
|
||||
fi
|
||||
# Since the settings will not work, stay in the loop
|
||||
DNSSettingsCorrect=False
|
||||
# Otherwise,
|
||||
else
|
||||
# Show the settings
|
||||
if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\\n DNS Server 1: $PIHOLE_DNS_1\\n DNS Server 2: ${PIHOLE_DNS_2}" ${r} ${c}); then
|
||||
# and break from the loop since the servers are valid
|
||||
DNSSettingsCorrect=True
|
||||
# Otherwise,
|
||||
else
|
||||
# If the settings are wrong, the loop continues
|
||||
DNSSettingsCorrect=False
|
||||
fi
|
||||
fi
|
||||
done
|
||||
else
|
||||
# Save the old Internal Field Separator in a variable
|
||||
OIFS=$IFS
|
||||
# and set the new one to newline
|
||||
IFS=$'\n'
|
||||
for DNSServer in ${DNS_SERVERS}
|
||||
do
|
||||
DNSName="$(cut -d';' -f1 <<< "${DNSServer}")"
|
||||
if [[ "${DNSchoices}" == "${DNSName}" ]]
|
||||
then
|
||||
printf "%s\\n" "${DNSName}"
|
||||
PIHOLE_DNS_1="$(cut -d';' -f2 <<< "${DNSServer}")"
|
||||
PIHOLE_DNS_2="$(cut -d';' -f3 <<< "${DNSServer}")"
|
||||
break
|
||||
fi
|
||||
done
|
||||
# Restore the IFS to what it was
|
||||
IFS=${OIFS}
|
||||
fi
|
||||
}
|
||||
|
||||
# Allow the user to enable/disable logging
|
||||
@@ -1342,6 +1341,12 @@ installConfigs() {
|
||||
printf "\\n %b Installing configs from %s...\\n" "${INFO}" "${PI_HOLE_LOCAL_REPO}"
|
||||
# Make sure Pi-hole's config files are in place
|
||||
version_check_dnsmasq
|
||||
|
||||
# Install list of DNS servers
|
||||
# Format: Name;Primary IPv4;Secondary IPv4;Primary IPv6;Secondary IPv6
|
||||
# Some values may be empty (for example: DNS servers without IPv6 support)
|
||||
echo "${DNS_SERVERS}" > "${PI_HOLE_CONFIG_DIR}/dns-servers.conf"
|
||||
|
||||
# Install empty file if it does not exist
|
||||
if [[ ! -f "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" ]]; then
|
||||
if ! install -o pihole -g pihole -m 664 /dev/null "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" &>/dev/null; then
|
||||
@@ -1437,9 +1442,9 @@ stop_service() {
|
||||
}
|
||||
|
||||
# Start/Restart service passed in as argument
|
||||
restart_service() {
|
||||
start_service() {
|
||||
# Local, named variables
|
||||
local str="Restarting ${1} service"
|
||||
local str="Starting ${1} service"
|
||||
printf " %b %s..." "${INFO}" "${str}"
|
||||
# If systemctl exists,
|
||||
if is_command systemctl ; then
|
||||
@@ -1909,9 +1914,8 @@ installPihole() {
|
||||
installCron
|
||||
# Install the logrotate file
|
||||
installLogrotate
|
||||
# Check if dnsmasq is present. If so, disable it and back up any possible
|
||||
# config file
|
||||
disable_dnsmasq
|
||||
# Check if FTL is installed
|
||||
FTLdetect || printf " %b FTL Engine not installed\\n" "${CROSS}"
|
||||
# Configure the firewall
|
||||
if [[ "${useUpdateVars}" == false ]]; then
|
||||
configureFirewall
|
||||
@@ -2134,6 +2138,7 @@ clone_or_update_repos() {
|
||||
# Download FTL binary to random temp directory and install FTL binary
|
||||
FTLinstall() {
|
||||
# Local, named variables
|
||||
local binary="${1}"
|
||||
local latesttag
|
||||
local str="Downloading and Installing FTL"
|
||||
printf " %b %s..." "${INFO}" "${str}"
|
||||
@@ -2151,7 +2156,8 @@ FTLinstall() {
|
||||
pushd "$(mktemp -d)" > /dev/null || { printf "Unable to make temporary directory for FTL binary download\\n"; return 1; }
|
||||
|
||||
# Always replace pihole-FTL.service
|
||||
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.service" "/etc/init.d/pihole-FTL"
|
||||
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/init.d/pihole-FTL" "/etc/init.d/pihole-FTL"
|
||||
install -T -m 0644 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/systemd/pihole-FTL.service" "/etc/systemd/system/pihole-FTL.service"
|
||||
|
||||
local ftlBranch
|
||||
local url
|
||||
@@ -2178,17 +2184,38 @@ FTLinstall() {
|
||||
if sha1sum --status --quiet -c "${binary}".sha1; then
|
||||
printf "transferred... "
|
||||
|
||||
# Stop pihole-FTL service if available
|
||||
stop_service pihole-FTL &> /dev/null
|
||||
# Before stopping FTL, we download the macvendor database
|
||||
curl -sSL "https://ftl.pi-hole.net/macvendor.db" -o "${PI_HOLE_CONFIG_DIR}/macvendor.db" || true
|
||||
|
||||
# Stop FTL
|
||||
stop_service pihole-FTL &> /dev/null
|
||||
# Install the new version with the correct permissions
|
||||
install -T -m 0755 "${binary}" /usr/bin/pihole-FTL
|
||||
|
||||
# Set net admin permissions so that FTL can serve DNS, DHCP and IMAP (for DHCPv6)
|
||||
setcap CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_NET_ADMIN+eip "/usr/bin/pihole-FTL"
|
||||
# Move back into the original directory the user was in
|
||||
popd > /dev/null || { printf "Unable to return to original directory after FTL binary download.\\n"; return 1; }
|
||||
|
||||
# Installed the FTL service
|
||||
# Install the FTL service
|
||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||
# dnsmasq can now be stopped and disabled if it exists
|
||||
if which dnsmasq &> /dev/null; then
|
||||
if check_service_active "dnsmasq";then
|
||||
printf " %b FTL can now resolve DNS Queries without dnsmasq running separately\\n" "${INFO}"
|
||||
stop_service dnsmasq
|
||||
disable_service dnsmasq
|
||||
fi
|
||||
fi
|
||||
|
||||
# Backup existing /etc/dnsmasq.conf if present and ensure that
|
||||
# /etc/dnsmasq.conf contains only "conf-dir=/etc/dnsmasq.d"
|
||||
local conffile="/etc/dnsmasq.conf"
|
||||
if [[ -f "${conffile}" ]]; then
|
||||
printf " %b Backing up %s to %s.old\\n" "${INFO}" "${conffile}" "${conffile}"
|
||||
mv "${conffile}" "${conffile}.old"
|
||||
fi
|
||||
# Create /etc/dnsmasq.conf
|
||||
echo "conf-dir=/etc/dnsmasq.d" > "${conffile}"
|
||||
|
||||
return 0
|
||||
# Otherwise,
|
||||
else
|
||||
@@ -2208,27 +2235,6 @@ FTLinstall() {
|
||||
fi
|
||||
}
|
||||
|
||||
disable_dnsmasq() {
|
||||
# dnsmasq can now be stopped and disabled if it exists
|
||||
if which dnsmasq &> /dev/null; then
|
||||
if check_service_active "dnsmasq";then
|
||||
printf " %b FTL can now resolve DNS Queries without dnsmasq running separately\\n" "${INFO}"
|
||||
stop_service dnsmasq
|
||||
disable_service dnsmasq
|
||||
fi
|
||||
fi
|
||||
|
||||
# Backup existing /etc/dnsmasq.conf if present and ensure that
|
||||
# /etc/dnsmasq.conf contains only "conf-dir=/etc/dnsmasq.d"
|
||||
local conffile="/etc/dnsmasq.conf"
|
||||
if [[ -f "${conffile}" ]]; then
|
||||
printf " %b Backing up %s to %s.old\\n" "${INFO}" "${conffile}" "${conffile}"
|
||||
mv "${conffile}" "${conffile}.old"
|
||||
fi
|
||||
# Create /etc/dnsmasq.conf
|
||||
echo "conf-dir=/etc/dnsmasq.d" > "${conffile}"
|
||||
}
|
||||
|
||||
get_binary_name() {
|
||||
# This gives the machine architecture which may be different from the OS architecture...
|
||||
local machine
|
||||
@@ -2386,7 +2392,7 @@ FTLdetect() {
|
||||
printf "\\n %b FTL Checks...\\n\\n" "${INFO}"
|
||||
|
||||
if FTLcheckUpdate ; then
|
||||
FTLinstall || return 1
|
||||
FTLinstall "${binary}" || return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -2546,11 +2552,6 @@ main() {
|
||||
else
|
||||
LIGHTTPD_ENABLED=false
|
||||
fi
|
||||
# Check if FTL is installed - do this early on as FTL is a hard dependency for Pi-hole
|
||||
if ! FTLdetect; then
|
||||
printf " %b FTL Engine not installed\\n" "${CROSS}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Install and log everything to a file
|
||||
installPihole | tee -a /proc/$$/fd/3
|
||||
@@ -2581,7 +2582,7 @@ main() {
|
||||
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
|
||||
|
||||
if [[ "${LIGHTTPD_ENABLED}" == true ]]; then
|
||||
restart_service lighttpd
|
||||
start_service lighttpd
|
||||
enable_service lighttpd
|
||||
else
|
||||
printf " %b Lighttpd is disabled, skipping service restart\\n" "${INFO}"
|
||||
@@ -2596,7 +2597,7 @@ main() {
|
||||
# Fixes a problem reported on Ubuntu 18.04 where trying to start
|
||||
# the service before enabling causes installer to exit
|
||||
enable_service pihole-FTL
|
||||
restart_service pihole-FTL
|
||||
start_service pihole-FTL
|
||||
|
||||
# Download and compile the aggregated block list
|
||||
runGravity
|
||||
|
8
pihole
8
pihole
@@ -144,10 +144,6 @@ Time:
|
||||
|
||||
elif [[ "${1}" == "0" ]]; then
|
||||
# Disable Pi-hole
|
||||
if grep -cq "BLOCKING_ENABLED=false" "${setupVars}"; then
|
||||
echo -e " ${INFO} Blocking already disabled, nothing to do"
|
||||
exit 0
|
||||
fi
|
||||
if [[ -e "${gravitylist}" ]]; then
|
||||
mv "${gravitylist}" "${gravitylist}.bck"
|
||||
echo "" > "${gravitylist}"
|
||||
@@ -197,10 +193,6 @@ Time:
|
||||
fi
|
||||
else
|
||||
# Enable Pi-hole
|
||||
if grep -cq "BLOCKING_ENABLED=true" "${setupVars}"; then
|
||||
echo -e " ${INFO} Blocking already enabled, nothing to do"
|
||||
exit 0
|
||||
fi
|
||||
echo -e " ${INFO} Enabling blocking"
|
||||
local str="Pi-hole Enabled"
|
||||
|
||||
|
@@ -481,10 +481,10 @@ def test_FTL_download_aarch64_no_errors(Pihole):
|
||||
'''
|
||||
confirms only aarch64 package is downloaded for FTL engine
|
||||
'''
|
||||
# mock uname to return generic platform
|
||||
download_binary = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
binary="pihole-FTL-aarch64-linux-gnu"
|
||||
FTLinstall
|
||||
FTLinstall pihole-FTL-aarch64-linux-gnu
|
||||
''')
|
||||
expected_stdout = tick_box + ' Downloading and Installing FTL'
|
||||
assert expected_stdout in download_binary.stdout
|
||||
@@ -495,26 +495,10 @@ def test_FTL_download_unknown_fails_no_errors(Pihole):
|
||||
'''
|
||||
confirms unknown binary is not downloaded for FTL engine
|
||||
'''
|
||||
# mock uname to return generic platform
|
||||
download_binary = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
binary="pihole-FTL-mips"
|
||||
FTLinstall
|
||||
''')
|
||||
expected_stdout = cross_box + ' Downloading and Installing FTL'
|
||||
assert expected_stdout in download_binary.stdout
|
||||
error1 = 'Error: URL https://github.com/pi-hole/FTL/releases/download/'
|
||||
assert error1 in download_binary.stdout
|
||||
error2 = 'not found'
|
||||
assert error2 in download_binary.stdout
|
||||
|
||||
|
||||
def test_FTL_download_binary_unset_no_errors(Pihole):
|
||||
'''
|
||||
confirms unset binary variable does not download FTL engine
|
||||
'''
|
||||
download_binary = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
FTLinstall
|
||||
FTLinstall pihole-FTL-mips
|
||||
''')
|
||||
expected_stdout = cross_box + ' Downloading and Installing FTL'
|
||||
assert expected_stdout in download_binary.stdout
|
||||
|
Reference in New Issue
Block a user