Signed-off-by: Adam Warner <adamw@rner.email>
This commit is contained in:
Adam Warner 2018-07-27 00:27:06 +01:00
parent 384b588a2d
commit 9b1356ad01
No known key found for this signature in database
GPG Key ID: F5410858022DA5EB
3 changed files with 15 additions and 156 deletions

View File

@ -40,11 +40,9 @@ COL_LIGHT_PURPLE="${COL_PURPLE}"
COL_BROWN="${COL_YELLOW}"
COL_LIGHT_GRAY="${COL_GRAY}"
COL_DARK_GRAY="${COL_GRAY}"
COL_LIGHT_YELLOW="${COL_YELLOW}"
TICK="[${COL_GREEN}✓${COL_NC}]"
CROSS="[${COL_RED}✗${COL_NC}]"
EXCL="[${COL_YELLOW}!${COL_NC}]"
INFO="[i]"
QST="[?]"
DONE="${COL_GREEN} done!${COL_NC}"

View File

@ -37,10 +37,6 @@ setupVars=/etc/pihole/setupVars.conf
lighttpdConfig=/etc/lighttpd/lighttpd.conf
# This is a file used for the colorized output
coltable=/opt/pihole/COL_TABLE
# Defining a boolean variable for tracking presence of dnsmasq
dnsmasq_flag=false
# Defining a boolean variable for tracking presence of systemd-resolved
systemd_resolved_flag=false
# We store several other folders and
webInterfaceGitUrl="https://github.com/pi-hole/AdminLTE.git"
@ -86,16 +82,13 @@ skipSpaceCheck=false
reconfigure=false
runUnattended=false
INSTALL_WEB_SERVER=true
skipDNSPortCheck=false
# Check arguments for the undocumented flags
for var in "$@"; do
case "$var" in
"--reconfigure" ) reconfigure=true skipDNSPortCheck=true;;
"--reconfigure" ) reconfigure=true;;
"--i_do_not_follow_recommendations" ) skipSpaceCheck=true;;
"--unattended" ) runUnattended=true;;
"--disable-install-webserver" ) INSTALL_WEB_SERVER=false;;
"--skip-DNS-port-check" ) skipDNSPortCheck=true;;
esac
done
@ -109,11 +102,8 @@ else
COL_NC='\e[0m' # No Color
COL_LIGHT_GREEN='\e[1;32m'
COL_LIGHT_RED='\e[1;31m'
COL_LIGHT_YELLOW='\e[1;33m'
COL_LIGHT_CYAN='\e[1;96m'
TICK="[${COL_LIGHT_GREEN}${COL_NC}]"
CROSS="[${COL_LIGHT_RED}${COL_NC}]"
EXCL="[${COL_LIGHT_YELLOW}!${COL_NC}]"
INFO="[i]"
# shellcheck disable=SC2034
DONE="${COL_LIGHT_GREEN} done!${COL_NC}"
@ -148,84 +138,6 @@ show_ascii_berry() {
}
# Compatibility
port_53_probe(){
# Probe localhost via 127.0.0.1 for open port 53 and store process name if port 53 is occupied
if (echo > /dev/tcp/127.0.0.1/53) >/dev/null 2>&1; then
# What process is using 53?
who53="$(${SUDO} lsof -i :53 +c 0 | awk 'FNR==2{ print $1 }')"
fi
}
port_53_check(){
# Print info regarding probing for open port 53
echo -e " ${INFO} Testing for port 53 availability...${COL_NC}"
port_53_probe
# Check running process and see if it's blank
if [ -z "$who53" ]; then
echo -e " ${TICK} ${COL_LIGHT_GREEN}Port 53 is available.${COL_NC}"
# Check running process and see if it's pihole-FTL
elif [ "$who53" = "pihole-FTL" ]; then
# Proceed with install
echo -e " ${TICK} Port 53 is in use by our resolver ${COL_LIGHT_GREEN}($who53)${COL_NC}, proceeding with setup"
elif [ "$who53" = "dnsmasq" ] && [[ $skipDNSPortCheck = "true" ]]; then
# If dnsmasq is present, set the dnsmasq-flag to true for future reference
# (after packages and dependencies are installed).
# dnsmasq will be disabled at end of install, prior to FTLDNS start.
echo -e " ${EXCL} Port 53 is in use by ${COL_LIGHT_RED}$who53${COL_NC}."
echo -e " --skip-DNS-port-check flag was used. The installer ${COL_LIGHT_RED}will disable $who53${COL_NC} after dependencies and packages"
echo -e " have been downloaded, and replace dnsmasq with FTLDNS."
dnsmasq_flag=true
elif [ "$who53" = "dnsmasq" ] && [[ $skipDNSPortCheck = "false" ]]; then
# If dnsmasq is present, set the dnsmasq-flag to true for future reference
# (after packages and dependencies are installed).
# dnsmasq will be disabled at end of install, prior to FTLDNS start.
echo -e " ${EXCL} Port 53 is in use by ${COL_LIGHT_RED}$who53${COL_NC}."
echo -e " In order for the installer to proceed, ${COL_LIGHT_RED}$who53${COL_NC} needs to be disabled."
echo -e " Please re-run the installer with the following command:"
echo -e " ${COL_LIGHT_CYAN}curl -sSL https://install.pi-hole.net | bash -s -- --skip-DNS-port-check${COL_NC}"
exit 0
elif [ "$who53" = "systemd-resolve" ] && [[ $skipDNSPortCheck = "true" ]]; then
# If systemd-resolved is present, set the systemd-resolved-flag to true for future reference
# (after packages and dependencies are installed).
# systemd-resolved will be disabled at end of install, prior to FTLDNS start.
echo -e " ${EXCL} Port 53 is in use by ${COL_LIGHT_RED}$who53${COL_NC}."
echo -e " --skip-DNS-port-check flag was used. The installer ${COL_LIGHT_RED}will disable $who53${COL_NC} after dependencies and packages"
echo -e " have been downloaded, and replace the system DNS resolver with FTLDNS."
systemd_resolved_flag=true
elif [ "$who53" = "systemd-resolve" ] && [[ $skipDNSPortCheck = "false" ]]; then
# If systemd-resolved is present, set the systemd-resolved-flag to true for future reference
# (after packages and dependencies are installed).
# systemd-resolved will be disabled at end of install, prior to FTLDNS start.
echo -e " ${EXCL} Port 53 is in use by ${COL_LIGHT_RED}$who53${COL_NC}."
echo -e " In order for the installer to proceed, ${COL_LIGHT_RED}$who53${COL_NC} needs to be disabled."
echo -e " Please re-run the installer with the following command:"
echo -e " ${COL_LIGHT_CYAN}curl -sSL https://install.pi-hole.net | bash -s -- --skip-DNS-port-check${COL_NC}"
exit 0
else
# Port 53 is used by something else, stop install
echo -e " ${EXCL} ${COL_LIGHT_YELLOW}WARNING: Port 53 (mandatory for FTLDNS) is already in use by ${COL_LIGHT_RED}$who53${COL_NC}."
echo -e " Since this will interfere with the functionality of FTLDNS, the installer cannot continue."
echo -e " Please visit our discourse forum at ${COL_LIGHT_CYAN}https://discourse.pi-hole.net${COL_NC}"
echo -e " in order to get help related to this issue."
echo -e " ${COL_LIGHT_RED}Installer will now exit.${COL_NC}"
exit 0
fi
}
# Creating silent port 53 check
silent_port_53_check(){
# Probe localhost via 127.0.0.1 for open port 53 availability
port_53_probe
# Check running process and see if it's dnsmasq
if [ "$who53" = "dnsmasq" ]; then
# If dnsmasq is present, set the dnsmasq-flag to true for future reference
# (after packages and dependencies are installed).
# dnsmasq will be disabled at end of install, prior to FTLDNS start.
dnsmasq_flag=true
fi
}
distro_check() {
# If apt-get is installed, then we know it's part of the Debian family
if command -v apt-get &> /dev/null; then
@ -1468,59 +1380,25 @@ check_service_active() {
# Systemd-resolved's DNSStubListener and dnsmasq can't share port 53.
disable_resolved_stublistener() {
echo -e " ${INFO} Testing if systemd-resolved is enabled"
# Check if Systemd-resolved's DNSStubListener flag is present
if [[ $systemd_resolved_flag = "true" ]]; then
echo -en " ${INFO} Testing if systemd-resolved is enabled"
# Check if Systemd-resolved's DNSStubListener is enabled and active on port 53
if check_service_active "systemd-resolved"; then
# Check if DNSStubListener is enabled
echo -e " ${INFO} Testing if systemd-resolved DNSStub-Listener is active"
echo -en " ${OVER} ${INFO} Testing if systemd-resolved DNSStub-Listener is active"
if ( grep -E '#?DNSStubListener=yes' /etc/systemd/resolved.conf &> /dev/null ); then
# Disable the DNSStubListener to unbind it from port 53
# Note that this breaks dns functionality on host until dnsmasq/ftl are up and running
echo -e " ${TICK} Disabling systemd-resolved DNSStubListener"
echo -en "${OVER} ${TICK} Disabling systemd-resolved DNSStubListener"
# Make a backup of the original /etc/systemd/resolved.conf
# (This will need to be restored on uninstallation)
${SUDO} sed -r -i.orig 's/#?DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf
echo -e " ${TICK} Restarting systemd-resolved DNSStubListener"
${SUDO} systemctl reload-or-restart systemd-resolved
sed -r -i.orig 's/#?DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf
echo -e " and restarting systemd-resolved"
systemctl reload-or-restart systemd-resolved
else
echo -e " ${INFO} Systemd-resolved does not need to be restarted"
echo -e " ${INFO} DNSStubListener is not enabled"
echo -e "${OVER} ${INFO} Systemd-resolved does not need to be restarted"
fi
else
echo -e " ${INFO} Systemd-resolved is not enabled"
fi
}
disable_dnsmasq() {
# Check if dnsmasq flag is present.
echo -e " ${INFO} Checking if dnsmasq is enabled"
if [[ $dnsmasq_flag = "true" ]]; then
if ( grep -E '#?dns=dnsmasq' /etc/NetworkManager/NetworkManager.conf &> /dev/null ); then
# Disable dnsmasq from restarting when Network Manager restarts
# Note that this breaks dns functionality on host until FTLDNS is up and running
echo -e " ${TICK} Disabling dnsmasq from restarting when Network manager starts/restarts"
# Make a backup of the original /etc/NetworkManager/NetworkManager.conf
# (This will need to be restored on uninstallation)
${SUDO} sed -r -i.orig '/#?dns=dnsmasq/d' /etc/NetworkManager/NetworkManager.conf
echo -e " ${TICK} Restarting Network manager"
${SUDO} systemctl reload-or-restart NetworkManager
else
# Disabling dnsmasq via systemctl
echo -e " ${INFO} Disabling dnsmasq via systemctl"
${SUDO} systemctl disable dnsmasq &> /dev/null
fi
#setting dnsmasq_flag to false in order for the next check to validate or not
dnsmasq_flag=false
echo -e " ${INFO} Checking if dnsmasq is still running"
silent_port_53_check
if [[ $dnsmasq_flag = "true" ]]; then
echo -e " ${EXCL} dnsmasq still active, this is most likely due to the fact that ${COL_LIGHT_RED}dnsmasq"
echo -e " was loaded via a non convetional method. This might cause future conflicts with FTLDNS${COL_NC}"
${SUDO} pkill dnsmasq
echo -e " ${TICK} dnsmasq process killed"
fi
else
echo -e " ${INFO} dnsmasq is not enabled"
echo -e "${OVER} ${INFO} Systemd-resolved is not enabled"
fi
}
@ -2000,7 +1878,6 @@ update_dialogs() {
${opt1a})
echo -e " ${INFO} ${opt1a} option selected"
useUpdateVars=true
skipDNSPortCheck=true
;;
# reconfigure,
${opt2a})
@ -2413,8 +2290,6 @@ main() {
echo -e " ${TICK} ${str}"
# Show the Pi-hole logo so people know it's genuine since the logo and name are trademarked
show_ascii_berry
# Check for port 53 availability
port_53_check
make_temporary_log
# Otherwise,
else
@ -2546,20 +2421,11 @@ main() {
fi
fi
# Check for systemd-resolved flag and disable systemd-resolved-DNSStubListener before reloading resolved
# Check for and disable systemd-resolved-DNSStubListener before reloading resolved
# DNSStubListener needs to remain in place for installer to download needed files,
# so this change needs to be made after installation is complete,
# but before starting or restarting the FTLDNS service
if [[ $systemd_resolved_flag = "true" ]]; then
disable_resolved_stublistener
fi
# Check for dnsmasq flag and disable dnsmasq before starting FTLDNS
# dnsmasq needs to remain in place for installer to download needed files,
# so this change needs to be made after installation is complete,
# but before starting or restarting the FTLDNS service
if [[ $dnsmasq_flag = "true" ]]; then
disable_dnsmasq
fi
# but before starting or resarting the dnsmasq or ftl services
disable_resolved_stublistener
# If the Web server was installed,
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
@ -2574,6 +2440,7 @@ main() {
echo -e " ${INFO} Restarting services..."
# Start services
# Enable FTL
start_service pihole-FTL
enable_service pihole-FTL

View File

@ -158,12 +158,6 @@ removeNoPurge() {
systemctl reload-or-restart systemd-resolved
fi
# Restore dnsmasq via Network Manager
if [[ -e /etc/NetworkManager/NetworkManager.conf.orig ]]; then
${SUDO} cp /etc/NetworkManager/NetworkManager.conf.orig /etc/NetworkManager/NetworkManager.conf
systemctl reload-or-restart NetworkManager
fi
# Remove FTL
if command -v pihole-FTL &> /dev/null; then
echo -ne " ${INFO} Removing pihole-FTL..."