From 73c85ae68a931f777173b9d394f803c9a62104d2 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 10:30:55 +0100 Subject: [PATCH 01/15] remove duplicate calls to installConfigs --- automated install/basic-install.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 46abeb62..c9c16e8a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -820,7 +820,6 @@ installPihole() { getGitFiles installScripts installConfigs - installConfigs CreateLogFile configureSelinux installPiholeWeb @@ -837,7 +836,6 @@ updatePihole() { getGitFiles installScripts installConfigs - installConfigs CreateLogFile configureSelinux installPiholeWeb From 7684069d0b7012190f6efea8af7d6552830682de Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 10:33:04 +0100 Subject: [PATCH 02/15] verifyFreeDiskSpace BEFORE installing any dependencies --- 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 c9c16e8a..7388dcd7 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -926,13 +926,13 @@ if [[ -f ${setupVars} ]];then fi # Start the installer +# Verify there is enough disk space for the install +verifyFreeDiskSpace # Install packages used by this installation script installerDependencies if [[ ${useUpdateVars} == false ]]; then welcomeDialogs - # Verify there is enough disk space for the install - verifyFreeDiskSpace ${SUDO} mkdir -p /etc/pihole/ # Find IP used to route to outside world From 6c2ff950ee5ab0a353515b2ba363eabafbd7605b Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 10:33:59 +0100 Subject: [PATCH 03/15] remote duplicate ${SUDO} mkdir /etc/pihole --- 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 7388dcd7..5455de53 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -933,7 +933,6 @@ installerDependencies if [[ ${useUpdateVars} == false ]]; then welcomeDialogs - ${SUDO} mkdir -p /etc/pihole/ # Find IP used to route to outside world findIPRoute From 4e262d81f04374c7cba1d017757b02a157ac46de Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 10:39:09 +0100 Subject: [PATCH 04/15] wrap these vars in {} to matcht he rest of the script --- 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 5455de53..c372c410 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -166,9 +166,9 @@ verifyFreeDiskSpace() { fi # - Insufficient free disk space - elif [[ $existing_free_kilobytes -lt $required_free_kilobytes ]]; then + elif [[ ${existing_free_kilobytes} -lt ${required_free_kilobytes} ]]; then - whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $required_free_kilobytes KiloBytes.\nYou only have $existing_free_kilobytes KiloBytes free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c + whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $required_free_kilobytes KiloBytes.\nYou only have $existing_free_kilobytes KiloBytes free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" ${r} ${c} echo "$existing_free_kilobytes is less than $required_free_kilobytes" echo "Insufficient free space, exiting..." exit 1 From 6f780316c4a6c5904b7751b5bcd56a291d986334 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 11:09:14 +0100 Subject: [PATCH 05/15] remove whiptail dependency from verifyFreeDiskSpace. Add argument detection to skip disk space. This is because curling to bash does not support waiting for user input. --- automated install/basic-install.sh | 33 +++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index c372c410..f70aeed0 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -149,27 +149,27 @@ verifyFreeDiskSpace() { # 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 5MB one day of logs.) # - Fourdee: Local ensures the variable is only created, and accessible within this function/void. Generally considered a "good" coding practice for non-global variables. + echo "::: Verifying free disk space..." local required_free_kilobytes=51200 local existing_free_kilobytes=$(df -Pk | grep -m1 '\/$' | awk '{print $4}') # - Unknown free disk space , not a integer if ! [[ "$existing_free_kilobytes" =~ ^([0-9])+$ ]]; then - - whiptail --title "Unknown free disk space" --yesno "We were unable to determine available free disk space on this system.\n\nYou may override this check and force the installation, however, it is not recommended.\n\nWould you like to continue with the installation?" --defaultno --backtitle "Pi-hole" ${r} ${c} - local choice=$? - if (( $choice != 0 )); then - - echo "non-integer value from existing_free_kilobytes ($existing_free_kilobytes)" - echo "Unknown free space, user aborted, exiting..." - exit 1 - - fi - + echo "::: Unknown free disk space!" + echo "::: We were unable to determine available free disk space on this system." + echo "::: You may override this check and force the installation, however, it is not recommended" + echo "::: To do so, pass the argument '--force' to the install script" + echo "::: eg. curl -L https://install.pi-hole.net | bash /dev/stdin --force" + exit 1 # - Insufficient free disk space elif [[ ${existing_free_kilobytes} -lt ${required_free_kilobytes} ]]; then + echo "::: Insufficient Disk Space!" + echo "::: Your system appears to be low on disk space. pi-hole recommends a minimum of $required_free_kilobytes KiloBytes." + echo "::: You only have $existing_free_kilobytes KiloBytes free." + echo "::: If this is a new install you may need to expand your disk." + echo "::: Try running 'sudo raspi-config', and choose the 'expand file system option'" + echo "::: After rebooting, run this installation again. (curl -L https://install.pi-hole.net | bash)" - whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $required_free_kilobytes KiloBytes.\nYou only have $existing_free_kilobytes KiloBytes free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" ${r} ${c} - echo "$existing_free_kilobytes is less than $required_free_kilobytes" echo "Insufficient free space, exiting..." exit 1 @@ -927,7 +927,12 @@ fi # Start the installer # Verify there is enough disk space for the install -verifyFreeDiskSpace +if [ $1 = "--force" ]; then + echo "::: --force passed to script, skipping free disk space verification!" +else + verifyFreeDiskSpace +fi + # Install packages used by this installation script installerDependencies From aca5064743ed9639ca69eb03c031de51147fc22d Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 11:16:48 +0100 Subject: [PATCH 06/15] --force seems to light. lets try --i_do_not_follow_recommendations --- automated install/basic-install.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index f70aeed0..08c2bd6a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -158,8 +158,8 @@ verifyFreeDiskSpace() { echo "::: Unknown free disk space!" echo "::: We were unable to determine available free disk space on this system." echo "::: You may override this check and force the installation, however, it is not recommended" - echo "::: To do so, pass the argument '--force' to the install script" - echo "::: eg. curl -L https://install.pi-hole.net | bash /dev/stdin --force" + echo "::: To do so, pass the argument '--i_do_not_follow_recommendations' to the install script" + echo "::: eg. curl -L https://install.pi-hole.net | bash /dev/stdin --i_do_not_follow_recommendations" exit 1 # - Insufficient free disk space elif [[ ${existing_free_kilobytes} -lt ${required_free_kilobytes} ]]; then @@ -927,8 +927,9 @@ fi # Start the installer # Verify there is enough disk space for the install -if [ $1 = "--force" ]; then - echo "::: --force passed to script, skipping free disk space verification!" +if [ $1 = "--i_do_not_follow_recommendations" ]; then + echo "::: ----i_do_not_follow_recommendations passed to script" + echo "::: skipping free disk space verification!" else verifyFreeDiskSpace fi From c281b4790583527d22ee8841833fcec3990e3327 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 12:44:33 +0100 Subject: [PATCH 07/15] Mover {SUDO} mkdir -p /etc/pihole/ back to the beginning. --- automated install/basic-install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 08c2bd6a..4d8c602a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -804,7 +804,6 @@ installPihole() { checkForDependencies # done stopServices setUser - ${SUDO} mkdir -p /etc/pihole/ if [ ! -d "/var/www/html" ]; then ${SUDO} mkdir -p /var/www/html fi @@ -939,7 +938,7 @@ installerDependencies if [[ ${useUpdateVars} == false ]]; then welcomeDialogs - + ${SUDO} mkdir -p /etc/pihole/ # Find IP used to route to outside world findIPRoute # Find interfaces and let the user choose one From 28ef8068c84cecec9c3a1d4f18bc179b151af654 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Wed, 5 Oct 2016 01:20:30 +0200 Subject: [PATCH 08/15] add mimetype for .svg Chrome does not display .svg-images without the correct mimetype --- advanced/lighttpd.conf.fedora | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advanced/lighttpd.conf.fedora b/advanced/lighttpd.conf.fedora index 30784b1a..8b8e0692 100644 --- a/advanced/lighttpd.conf.fedora +++ b/advanced/lighttpd.conf.fedora @@ -46,7 +46,8 @@ mimetype.assign = ( ".png" => "image/png", ".css" => "text/css; charset=utf-8", ".js" => "application/javascript", ".json" => "application/json", - ".txt" => "text/plain" ) + ".txt" => "text/plain", + ".svg" => "image/svg+xml" ) # default listening port for IPv6 falls back to the IPv4 port #include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port From 5382b4fa3785b1f2f16201436826a3ea1cd8c725 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 5 Oct 2016 09:42:15 -0700 Subject: [PATCH 09/15] Change installScripts to use install Use the install program instead of copying files and directories in installScripts function. --- automated install/basic-install.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 4d8c602a..63ce926f 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -526,11 +526,8 @@ installScripts() { # Install the scripts from /etc/.pihole to their various locations ${SUDO} echo ":::" ${SUDO} echo -n "::: Installing scripts to /opt/pihole..." - if [ ! -d /opt/pihole ]; then - ${SUDO} mkdir /opt/pihole - ${SUDO} chown "$USER":root /opt/pihole - ${SUDO} chmod u+srwx /opt/pihole - fi + ${SUDO} install -o ${USER} -m755 -d /opt/pihole + ${SUDO} cp /etc/.pihole/gravity.sh /opt/pihole/gravity.sh ${SUDO} cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh ${SUDO} cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh From 36987cb1cca0169adc9c655c9c951c04df2c9ded Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 5 Oct 2016 09:57:48 -0700 Subject: [PATCH 10/15] Continue migration to `install` --- automated install/basic-install.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 63ce926f..ed9fa7e7 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -526,13 +526,11 @@ installScripts() { # Install the scripts from /etc/.pihole to their various locations ${SUDO} echo ":::" ${SUDO} echo -n "::: Installing scripts to /opt/pihole..." - ${SUDO} install -o ${USER} -m755 -d /opt/pihole - - ${SUDO} cp /etc/.pihole/gravity.sh /opt/pihole/gravity.sh - ${SUDO} cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh - ${SUDO} cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh - ${SUDO} cp /etc/.pihole/advanced/Scripts/blacklist.sh /opt/pihole/blacklist.sh - ${SUDO} cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /opt/pihole/piholeDebug.sh + ${SUDO} install -o "${USER}" -m755 -d /opt/pihole + + cd /etc/.pihole/ + + ${SUDO} install cp "${USER}" -m755 -d /opt/pihole/ gravity.sh chronometer.sh whitelist.sh blacklist.sh piholeDebug.sh ${SUDO} cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh ${SUDO} cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh ${SUDO} cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh From e8bb4a7e363c4316e2832af5377bcce3620466ad Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 5 Oct 2016 10:14:36 -0700 Subject: [PATCH 11/15] Continue migration to `install` --- automated install/basic-install.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index ed9fa7e7..12fccfa0 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -530,12 +530,8 @@ installScripts() { cd /etc/.pihole/ - ${SUDO} install cp "${USER}" -m755 -d /opt/pihole/ gravity.sh chronometer.sh whitelist.sh blacklist.sh piholeDebug.sh - ${SUDO} cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh - ${SUDO} cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh - ${SUDO} cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh - ${SUDO} cp /etc/.pihole/advanced/Scripts/version.sh /opt/pihole/version.sh - ${SUDO} chmod 755 /opt/pihole/gravity.sh /opt/pihole/chronometer.sh /opt/pihole/whitelist.sh /opt/pihole/blacklist.sh /opt/pihole/piholeLogFlush.sh /opt/pihole/uninstall.sh /opt/pihole/setupLCD.sh /opt/pihole/version.sh + ${SUDO} install -o "${USER}" -Dm755 -t /opt/pihole/ gravity.sh + ${SUDO} install -o "${USER}" -Dm755 -t /opt/pihole/ ./advanced/Scripts/*.sh ${SUDO} cp /etc/.pihole/pihole /usr/local/bin/pihole ${SUDO} chmod 755 /usr/local/bin/pihole ${SUDO} cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole From 3600fd277e0385496bd496e350f5ed6d23f84a0a Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 5 Oct 2016 10:16:56 -0700 Subject: [PATCH 12/15] Don't need `sudo` to echo to term. --- automated install/basic-install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 12fccfa0..56b9934e 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -524,8 +524,8 @@ versionCheckDNSmasq(){ installScripts() { # Install the scripts from /etc/.pihole to their various locations - ${SUDO} echo ":::" - ${SUDO} echo -n "::: Installing scripts to /opt/pihole..." + echo ":::" + echo -n "::: Installing scripts to /opt/pihole..." ${SUDO} install -o "${USER}" -m755 -d /opt/pihole cd /etc/.pihole/ @@ -545,7 +545,7 @@ installScripts() { fi done - ${SUDO} echo " done." + echo " done." } installConfigs() { From 3bbac9a5f219cc07831a1e5425d1266a2e650135 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 5 Oct 2016 10:19:47 -0700 Subject: [PATCH 13/15] `install` pihole --- 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 56b9934e..6308a0ed 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -532,8 +532,8 @@ installScripts() { ${SUDO} install -o "${USER}" -Dm755 -t /opt/pihole/ gravity.sh ${SUDO} install -o "${USER}" -Dm755 -t /opt/pihole/ ./advanced/Scripts/*.sh - ${SUDO} cp /etc/.pihole/pihole /usr/local/bin/pihole - ${SUDO} chmod 755 /usr/local/bin/pihole + ${SUDO} install -o "${USER}" -Dm755 -t /usr/local/bin/ pihole + ${SUDO} cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole . /etc/bash_completion.d/pihole From 50d16d8215f2a7016d9cf3650a61e44814c1b8ba Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 5 Oct 2016 10:45:17 -0700 Subject: [PATCH 14/15] Finish `install` conversion for installScripts() --- 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 6308a0ed..84ef9788 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -534,7 +534,7 @@ installScripts() { ${SUDO} install -o "${USER}" -Dm755 -t /opt/pihole/ ./advanced/Scripts/*.sh ${SUDO} install -o "${USER}" -Dm755 -t /usr/local/bin/ pihole - ${SUDO} cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole + ${SUDO} install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole . /etc/bash_completion.d/pihole #Tidy up /usr/local/bin directory if installing over previous install. From 8c151c62ce3ab311d561d5048a53685e75d9b037 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 5 Oct 2016 10:46:10 -0700 Subject: [PATCH 15/15] echo's don't need sudo --- automated install/basic-install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 84ef9788..72b28d22 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -550,8 +550,8 @@ installScripts() { installConfigs() { # Install the configs from /etc/.pihole to their various locations - ${SUDO} echo ":::" - ${SUDO} echo "::: Installing configs..." + echo ":::" + echo "::: Installing configs..." versionCheckDNSmasq if [ ! -d "/etc/lighttpd" ]; then ${SUDO} mkdir /etc/lighttpd @@ -567,15 +567,15 @@ installConfigs() { stopServices() { # Stop dnsmasq and lighttpd - ${SUDO} echo ":::" - ${SUDO} echo -n "::: Stopping services..." + echo ":::" + echo -n "::: Stopping services..." #$SUDO service dnsmasq stop & spinner $! || true if [ -x "$(command -v systemctl)" ]; then ${SUDO} systemctl stop lighttpd & spinner $! || true else ${SUDO} service lighttpd stop & spinner $! || true fi - ${SUDO} echo " done." + echo " done." } installerDependencies() {