From bb3b1bc6bac4c57635385b61a3e6c567faf2b1a3 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 20 Jan 2018 05:13:55 -0800 Subject: [PATCH 1/5] Move ascii berry to after root check, stops the double berry for the sudo refire. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index d22775c4..7d8dbae9 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1897,8 +1897,6 @@ FTLdetect() { main() { ######## FIRST CHECK ######## - # Show the Pi-hole logo so people know it's genuine since the logo and name are trademarked - show_ascii_berry # Must be root to install local str="Root user check" echo "" @@ -1907,6 +1905,8 @@ main() { if [[ "${EUID}" -eq 0 ]]; then # they are root and all is good 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 # Otherwise, else # They do not have enough privileges, so let the user know From b2eb364a4b8302e312c31ffa8069881a3f558e8a Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 20 Jan 2018 05:29:38 -0800 Subject: [PATCH 2/5] Update header Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 7d8dbae9..125333ca 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2,7 +2,7 @@ # shellcheck disable=SC1090 # Pi-hole: A black hole for Internet advertisements -# (c) 2017 Pi-hole, LLC (https://pi-hole.net) +# (c) 2017-2018 Pi-hole, LLC (https://pi-hole.net) # Network-wide ad blocking via your own hardware. # # Installs and Updates Pi-hole @@ -14,7 +14,7 @@ # # Install with this command (from your Linux machine): # -# curl -L install.pi-hole.net | bash +# curl -sSL https://install.pi-hole.net | bash # -e option instructs bash to immediately exit if any command [1] has a non-zero exit status # We do not want users to end up with a partially working install, so we exit the script From a7f0137e5f3d2fa0452c5e60092b7fd7c872e2e7 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 20 Jan 2018 05:55:48 -0800 Subject: [PATCH 3/5] Use more secure installation log process. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 125333ca..9befba87 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -28,8 +28,7 @@ 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 -# We write to a temporary file before moving the log to the pihole folder -tmpLog=/tmp/pihole-install.log +# Location for final installation log storage instalLogLoc=/etc/pihole/install.log # This is an important file as it contains information specific to the machine it's being installed on setupVars=/etc/pihole/setupVars.conf @@ -1891,8 +1890,24 @@ FTLdetect() { # Install FTL FTLinstall "${binary}" || return 1 fi +} +make_temporary_log() { + # Create a random temporary file for the log + TEMPLOG=$(mktemp /tmp/pihole_temp.XXXXXX) + # Open handle 3 for templog + # https://stackoverflow.com/questions/18460186/writing-outputs-to-log-file-and-console + exec 3>"$TEMPLOG" + # Delete templog, but allow for addressing via file handle + # This lets us write to the log without having a temporary file on the drive, which + # is meant to be a security measure so there is not a lingering file on the drive during the debug process + rm "$TEMPLOG" +} +copy_to_install_log() { + # Copy the contents of file descriptor 3 into the install log + # Since we use color codes such as '\e[1;33m', they should be removed + cat /proc/$$/fd/3 | sed 's/\[[0-9;]\{1,5\}m//g' > "${installLogLoc}" } main() { @@ -2031,7 +2046,7 @@ main() { fi # Install and log everything to a file - installPihole | tee ${tmpLog} + installPihole | tee ${TEMPLOG} else # Source ${setupVars} to use predefined user variables in the functions source ${setupVars} @@ -2058,11 +2073,11 @@ main() { LIGHTTPD_ENABLED=$(service lighttpd status | awk '/Loaded:/ {print $0}' | grep -c 'enabled' || true) fi - updatePihole | tee ${tmpLog} + updatePihole | tee ${TEMPLOG} fi # Move the log file into /etc/pihole for storage - mv ${tmpLog} ${instalLogLoc} + copy_to_install_log if [[ "${INSTALL_WEB}" == true ]]; then # Add password to web UI if there is none From cacfe4d38716b4919c8e3efa6764ef3de4711c95 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 20 Jan 2018 06:20:06 -0800 Subject: [PATCH 4/5] Linting changes Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 9befba87..1c035d2e 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -29,7 +29,7 @@ set -e # It's still a work in progress, so you may see some variance in this guideline until it is complete # Location for final installation log storage -instalLogLoc=/etc/pihole/install.log +installLogLoc=/etc/pihole/install.log # This is an important file as it contains information specific to the machine it's being installed on setupVars=/etc/pihole/setupVars.conf # Pi-hole uses lighttpd as a Web server, and this is the config file for it @@ -1900,14 +1900,14 @@ make_temporary_log() { exec 3>"$TEMPLOG" # Delete templog, but allow for addressing via file handle # This lets us write to the log without having a temporary file on the drive, which - # is meant to be a security measure so there is not a lingering file on the drive during the debug process + # is meant to be a security measure so there is not a lingering file on the drive during the install process rm "$TEMPLOG" } copy_to_install_log() { # Copy the contents of file descriptor 3 into the install log # Since we use color codes such as '\e[1;33m', they should be removed - cat /proc/$$/fd/3 | sed 's/\[[0-9;]\{1,5\}m//g' > "${installLogLoc}" + sed 's/\[[0-9;]\{1,5\}m//g' < /proc/$$/fd/3 > "${installLogLoc}" } main() { @@ -1922,6 +1922,7 @@ 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 + make_temporary_log # Otherwise, else # They do not have enough privileges, so let the user know @@ -2046,7 +2047,7 @@ main() { fi # Install and log everything to a file - installPihole | tee ${TEMPLOG} + installPihole | tee -a /proc/$$/fd/3 else # Source ${setupVars} to use predefined user variables in the functions source ${setupVars} @@ -2072,11 +2073,10 @@ main() { # Value will either be 1, if true, or 0 LIGHTTPD_ENABLED=$(service lighttpd status | awk '/Loaded:/ {print $0}' | grep -c 'enabled' || true) fi - - updatePihole | tee ${TEMPLOG} + updatePihole | tee -a /proc/$$/fd/3 fi - # Move the log file into /etc/pihole for storage + # Copy the temp log file into final log location for storage copy_to_install_log if [[ "${INSTALL_WEB}" == true ]]; then @@ -2154,7 +2154,7 @@ main() { fi # Display where the log file is - echo -e "\\n ${INFO} The install log is located at: /etc/pihole/install.log + echo -e "\\n ${INFO} The install log is located at: ${INSTALL_LOG_LOC} ${COL_LIGHT_GREEN}${INSTALL_TYPE} Complete! ${COL_NC}" } From 954320361052e93cab2802fde6be02297befeba5 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 20 Jan 2018 08:45:41 -0800 Subject: [PATCH 5/5] Echo the right location for the log. Signed-off-by: Dan Schaper --- 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 1c035d2e..be5621a7 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2154,7 +2154,7 @@ main() { fi # Display where the log file is - echo -e "\\n ${INFO} The install log is located at: ${INSTALL_LOG_LOC} + echo -e "\\n ${INFO} The install log is located at: ${installLogLoc} ${COL_LIGHT_GREEN}${INSTALL_TYPE} Complete! ${COL_NC}" }