From f360959efc465233d57d4f0bbc5b385bbbbfea9c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 9 Jan 2019 19:26:19 +0100 Subject: [PATCH 01/35] Download macvendor database from ftl.pi-hole.net when downloading a new FTL binary. Users who want to update the database more frequently than on each FTL release can use the python script from the FTL repository to generate the database themselves. The macvendor database is an optional component so a failing download is no reason to interrupt the installer. Signed-off-by: DL6ER --- automated install/basic-install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 990b1f34..132a96e5 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2174,6 +2174,10 @@ FTLinstall() { # If we downloaded binary file (as opposed to text), if sha1sum --status --quiet -c "${binary}".sha1; then printf "transferred... " + + # Before stopping FTL, we download the macvendor database + curl -sSL "https://ftl.pi-hole.net/macvendor.db" -o "${PI_HOLE_CONFIG_DIR}/macvendor.db" + # Stop FTL stop_service pihole-FTL &> /dev/null # Install the new version with the correct permissions From 97decb3a73ad1127d6133203a0f8b3415f4d26c8 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Sun, 13 Jan 2019 15:51:30 +0100 Subject: [PATCH 02/35] Standardize DNS list and write to file for AdminLTE Signed-off-by: Sylvia van Os --- automated install/basic-install.sh | 223 +++++++++++++++-------------- 1 file changed, 116 insertions(+), 107 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index b6bf7b6d..03e5997d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -28,6 +28,21 @@ 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;; +Norton;199.85.126.10;199.85.127.10;; +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 @@ -902,15 +917,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) || \ @@ -920,113 +946,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}" + 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 + 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}") + # 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##*,}" + 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} + # 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 - # Do the same for the secondary server - if ! valid_ip "${PIHOLE_DNS_2}" && [[ "${PIHOLE_DNS_2}" ]]; then - PIHOLE_DNS_2=${strInvalid} + if [[ "${PIHOLE_DNS_2}" == "${strInvalid}" ]]; then + PIHOLE_DNS_2="" 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 + # 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 - # 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 + # If the settings are wrong, the loop continues + DNSSettingsCorrect=False fi - done - ;; - esac + 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 @@ -1325,6 +1328,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 From ebba32e1c4b80b15403ce55491dda3c9d0fbb463 Mon Sep 17 00:00:00 2001 From: Mark Drobnak Date: Sat, 19 Jan 2019 20:45:19 -0500 Subject: [PATCH 03/35] Remove Norton DNS Signed-off-by: Mark Drobnak --- automated install/basic-install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 6f8c8c2d..20eeffe1 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -33,7 +33,6 @@ 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;; -Norton;199.85.126.10;199.85.127.10;; 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 From 516ed83638a7344bf0d4d9970661f8a09d45198d Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 28 Jan 2019 20:48:30 +0100 Subject: [PATCH 04/35] Add "|| true" to the curl command as a failed download is no show-stopper for the overall install process. Signed-off-by: DL6ER --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 132a96e5..b7dd9a8d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2176,7 +2176,7 @@ FTLinstall() { printf "transferred... " # Before stopping FTL, we download the macvendor database - curl -sSL "https://ftl.pi-hole.net/macvendor.db" -o "${PI_HOLE_CONFIG_DIR}/macvendor.db" + 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 From dc91d4b1f90192fb71aa73e8af85c338bda2882e Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 Feb 2019 09:06:57 +0000 Subject: [PATCH 05/35] basic_install: If a static interface is already set up we are done Signed-off-by: Andreas Schneider --- automated install/basic-install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 8666e70a..acf5b92d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -873,6 +873,13 @@ setStaticIPv4() { # Local, named variables local IFCFG_FILE local CONNECTION_NAME + + # If a static interface is already configured, we are done. + if [[ -r "/etc/sysconfig/network/ifcfg-${PIHOLE_INTERFACE}" ]]; then + if grep -q '^BOOTPROTO=.static.' "/etc/sysconfig/network/ifcfg-${PIHOLE_INTERFACE}"; then + return 0 + fi + fi # For the Debian family, if dhcpcd.conf exists, if [[ -f "/etc/dhcpcd.conf" ]]; then # configure networking via dhcpcd From d5bbb2b6404301b07aecac2f7a8c913223f5af8d Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 Feb 2019 09:17:53 +0000 Subject: [PATCH 06/35] basic_install: Use a varibale for the pihole dashboard dir Signed-off-by: Andreas Schneider --- automated install/basic-install.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index acf5b92d..87347541 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -62,6 +62,7 @@ PI_HOLE_FILES=(chronometer list piholeDebug piholeLogFlush setupLCD update versi # This directory is where the Pi-hole scripts will be installed PI_HOLE_INSTALL_DIR="/opt/pihole" PI_HOLE_CONFIG_DIR="/etc/pihole" +PI_HOLE_BLOCKPAGE_DIR="/var/www/html/pihole" useUpdateVars=false adlistFile="/etc/pihole/adlists.list" @@ -1387,7 +1388,7 @@ installConfigs() { # Make sure the external.conf file exists, as lighttpd v1.4.50 crashes without it touch /etc/lighttpd/external.conf # if there is a custom block page in the html/pihole directory, replace 404 handler in lighttpd config - if [[ -f "/var/www/html/pihole/custom.php" ]]; then + if [[ -f "${PI_HOLE_BLOCKPAGE_DIR}/custom.php" ]]; then sed -i 's/^\(server\.error-handler-404\s*=\s*\).*$/\1"pihole\/custom\.php"/' /etc/lighttpd/lighttpd.conf fi # Make the directories if they do not exist and set the owners @@ -1653,13 +1654,13 @@ installPiholeWeb() { local str="Creating directory for blocking page, and copying files" printf " %b %s..." "${INFO}" "${str}" # Install the directory - install -d /var/www/html/pihole + install -d ${PI_HOLE_BLOCKPAGE_DIR} # and the blockpage - install -D ${PI_HOLE_LOCAL_REPO}/advanced/{index,blockingpage}.* /var/www/html/pihole/ + install -D ${PI_HOLE_LOCAL_REPO}/advanced/{index,blockingpage}.* ${PI_HOLE_BLOCKPAGE_DIR}/ # Remove superseded file - if [[ -e "/var/www/html/pihole/index.js" ]]; then - rm "/var/www/html/pihole/index.js" + if [[ -e "${PI_HOLE_BLOCKPAGE_DIR}/index.js" ]]; then + rm "${PI_HOLE_BLOCKPAGE_DIR}/index.js" fi printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}" From 838e1b19ecb6a58ba58a72acfd008810c8a7e07c Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 Feb 2019 09:23:23 +0000 Subject: [PATCH 07/35] basic_install: Set permissons for PI_HOLE_DASHBOARD_DIR Signed-off-by: Andreas Schneider --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 87347541..4e3e0636 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1654,7 +1654,7 @@ installPiholeWeb() { local str="Creating directory for blocking page, and copying files" printf " %b %s..." "${INFO}" "${str}" # Install the directory - install -d ${PI_HOLE_BLOCKPAGE_DIR} + install -d -m 0755 ${PI_HOLE_BLOCKPAGE_DIR} # and the blockpage install -D ${PI_HOLE_LOCAL_REPO}/advanced/{index,blockingpage}.* ${PI_HOLE_BLOCKPAGE_DIR}/ From f187b42a98b984f49d2df2ba20672f5f2497ceca Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 Feb 2019 09:30:43 +0000 Subject: [PATCH 08/35] basic_install: Define webroot globally as a variable Signed-off-by: Andreas Schneider --- automated install/basic-install.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 4e3e0636..5d0f6e23 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -52,9 +52,12 @@ lighttpdConfig=/etc/lighttpd/lighttpd.conf # This is a file used for the colorized output coltable=/opt/pihole/COL_TABLE +# Root of the web server +webroot="/var/www/html" + # We store several other directories and webInterfaceGitUrl="https://github.com/pi-hole/AdminLTE.git" -webInterfaceDir="/var/www/html/admin" +webInterfaceDir="${webroot}/admin" piholeGitUrl="https://github.com/pi-hole/pi-hole.git" PI_HOLE_LOCAL_REPO="/etc/.pihole" # These are the names of pi-holes files, stored in an array @@ -62,7 +65,7 @@ PI_HOLE_FILES=(chronometer list piholeDebug piholeLogFlush setupLCD update versi # This directory is where the Pi-hole scripts will be installed PI_HOLE_INSTALL_DIR="/opt/pihole" PI_HOLE_CONFIG_DIR="/etc/pihole" -PI_HOLE_BLOCKPAGE_DIR="/var/www/html/pihole" +PI_HOLE_BLOCKPAGE_DIR="${webroot}/pihole" useUpdateVars=false adlistFile="/etc/pihole/adlists.list" @@ -1668,9 +1671,9 @@ installPiholeWeb() { local str="Backing up index.lighttpd.html" printf " %b %s..." "${INFO}" "${str}" # If the default index file exists, - if [[ -f "/var/www/html/index.lighttpd.html" ]]; then + if [[ -f "${webroot}/index.lighttpd.html" ]]; then # back it up - mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig + mv ${webroot}/index.lighttpd.html ${webroot}/index.lighttpd.orig printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}" # Otherwise, else @@ -1880,15 +1883,15 @@ installPihole() { # If the user wants to install the Web interface, if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then - if [[ ! -d "/var/www/html" ]]; then + if [[ ! -d "${webroot}" ]]; then # make the Web directory if necessary - mkdir -p /var/www/html + install -d -m 0755 ${webroot} fi if [[ "${INSTALL_WEB_SERVER}" == true ]]; then # Set the owner and permissions - chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/www/html - chmod 775 /var/www/html + chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} ${webroot} + chmod 0775 ${webroot} # Give pihole access to the Web server group usermod -a -G ${LIGHTTPD_GROUP} pihole # If the lighttpd command is executable, From 2f0e6a6dda2cbfc7719d5197aaf2721889633002 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 Feb 2019 09:33:31 +0000 Subject: [PATCH 09/35] basic_install: Make sure the PI_HOLE_CONFIG_DIR exists Signed-off-by: Andreas Schneider --- automated install/basic-install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 5d0f6e23..bc8daa35 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1362,7 +1362,8 @@ installConfigs() { 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 [[ ! -r "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" ]]; then + install -d -m 0755 ${PI_HOLE_CONFIG_DIR} if ! install -o pihole -g pihole -m 664 /dev/null "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" &>/dev/null; then printf " %bError: Unable to initialize configuration file %s/pihole-FTL.conf\\n" "${COL_LIGHT_RED}" "${PI_HOLE_CONFIG_DIR}" return 1 From 2f189cd0762daf725862e7d10a3c7cf2771fec6f Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 Feb 2019 09:40:47 +0000 Subject: [PATCH 10/35] basic_install: There is no pihole group, remove it Only a user has been created beforehand. Only some distributions create a group with the same name based on their configuration. We cannot assume this is always the default. Signed-off-by: Andreas Schneider --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index bc8daa35..087e0b38 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1364,7 +1364,7 @@ installConfigs() { # Install empty file if it does not exist if [[ ! -r "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" ]]; then install -d -m 0755 ${PI_HOLE_CONFIG_DIR} - if ! install -o pihole -g pihole -m 664 /dev/null "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" &>/dev/null; then + if ! install -o pihole -m 664 /dev/null "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" &>/dev/null; then printf " %bError: Unable to initialize configuration file %s/pihole-FTL.conf\\n" "${COL_LIGHT_RED}" "${PI_HOLE_CONFIG_DIR}" return 1 fi From 860ec1a7c4313412456d7858ac86f0305105f3a7 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 Feb 2019 13:45:52 +0100 Subject: [PATCH 11/35] basic_install: Use install for sudoers Signed-off-by: Andreas Schneider --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 087e0b38..110399f8 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1689,7 +1689,7 @@ installPiholeWeb() { # Make the .d directory if it doesn't exist mkdir -p /etc/sudoers.d/ # and copy in the pihole sudoers file - cp ${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole.sudo /etc/sudoers.d/pihole + install -m 0640 ${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole.sudo /etc/sudoers.d/pihole # Add lighttpd user (OS dependent) to sudoers file echo "${LIGHTTPD_USER} ALL=NOPASSWD: /usr/local/bin/pihole" >> /etc/sudoers.d/pihole From cd9fadbc441adbf5c2a97702ff60062a50847d77 Mon Sep 17 00:00:00 2001 From: Nils Bergmann Date: Sat, 16 Feb 2019 15:32:56 +0100 Subject: [PATCH 12/35] Remove protocol determination No protocol determination is neede, if you just use double slash. Signed-off-by: Nils Bergmann --- advanced/index.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/advanced/index.php b/advanced/index.php index 49eb0f45..78135e1a 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -40,13 +40,6 @@ $validExtTypes = array("asp", "htm", "html", "php", "rss", "xml", ""); // Get extension of current URL $currentUrlExt = pathinfo($_SERVER["REQUEST_URI"], PATHINFO_EXTENSION); -// Check if this is served over HTTP or HTTPS -if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") { - $proto = "https"; -} else { - $proto = "http"; -} - // Set mobile friendly viewport $viewPort = ''; @@ -229,10 +222,10 @@ setHeader(); - - + + ● <?=$serverName ?> - +