From f270f7430c655249d9274553697c558c3b9b04e9 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 5 May 2017 22:10:24 +0100 Subject: [PATCH 1/8] Update block page. Allow for setupVars setting of CUSTOMBLOCKPAGE (bool) to prevent it being overwritten --- automated install/basic-install.sh | 34 +++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index c65ef49f..ca45a256 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -35,7 +35,7 @@ IPV4_ADDRESS="" IPV6_ADDRESS="" QUERY_LOGGING=true INSTALL_WEB=true - +CUSTOMBLOCKPAGE=false # Find the rows and columns will default to 80x24 is it can not be detected screen_size=$(stty size 2>/dev/null || echo 24 80) @@ -866,30 +866,48 @@ CreateLogFile() { } installPiholeWeb() { + + if [ -f ${setupVars} ]; then + . ${setupVars} + fi # Install the web interface echo ":::" - echo "::: Installing pihole custom index page..." + echo -n "::: Installing index.php..." if [ -d "/var/www/html/pihole" ]; then if [ -f "/var/www/html/pihole/index.php" ]; then - echo "::: Existing index.php detected, not overwriting" + if [[ ${CUSTOMBLOCKPAGE} == true ]]; then + echo " Existing index.php detected, not overwriting" + else + cp ${PI_HOLE_LOCAL_REPO}/advanced/index.php /var/www/html/pihole/ + echo " done!" + fi else - echo -n "::: index.php missing, replacing... " cp ${PI_HOLE_LOCAL_REPO}/advanced/index.php /var/www/html/pihole/ echo " done!" fi + echo -n "::: Installing index.js..." if [ -f "/var/www/html/pihole/index.js" ]; then - echo "::: Existing index.js detected, not overwriting" + if [[ ${CUSTOMBLOCKPAGE} == true ]]; then + echo " Existing index.js detected, not overwriting" + else + cp ${PI_HOLE_LOCAL_REPO}/advanced/index.js /var/www/html/pihole/ + echo " done!" + fi else - echo -n "::: index.js missing, replacing... " cp ${PI_HOLE_LOCAL_REPO}/advanced/index.js /var/www/html/pihole/ echo " done!" fi + echo -n "::: Installing blockingpage.css..." if [ -f "/var/www/html/pihole/blockingpage.css" ]; then - echo "::: Existing blockingpage.css detected, not overwriting" + if [[ ${CUSTOMBLOCKPAGE} == true ]]; then + echo " Existing blockingpage.css detected, not overwriting" + else + cp ${PI_HOLE_LOCAL_REPO}/advanced/blockingpage.css /var/www/html/pihole + echo " done!" + fi else - echo -n "::: blockingpage.css missing, replacing... " cp ${PI_HOLE_LOCAL_REPO}/advanced/blockingpage.css /var/www/html/pihole echo " done!" fi From 5cd2c77d9897ae84d6494a4397fbbd22013289d2 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 5 May 2017 22:24:40 +0100 Subject: [PATCH 2/8] simplify --- automated install/basic-install.sh | 35 +----------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index ca45a256..eaa3413d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -874,44 +874,11 @@ installPiholeWeb() { echo ":::" echo -n "::: Installing index.php..." if [ -d "/var/www/html/pihole" ]; then - if [ -f "/var/www/html/pihole/index.php" ]; then - if [[ ${CUSTOMBLOCKPAGE} == true ]]; then - echo " Existing index.php detected, not overwriting" - else + if [[ ${CUSTOMBLOCKPAGE} == false ]]; then cp ${PI_HOLE_LOCAL_REPO}/advanced/index.php /var/www/html/pihole/ - echo " done!" - fi - else - cp ${PI_HOLE_LOCAL_REPO}/advanced/index.php /var/www/html/pihole/ - echo " done!" - fi - - echo -n "::: Installing index.js..." - if [ -f "/var/www/html/pihole/index.js" ]; then - if [[ ${CUSTOMBLOCKPAGE} == true ]]; then - echo " Existing index.js detected, not overwriting" - else cp ${PI_HOLE_LOCAL_REPO}/advanced/index.js /var/www/html/pihole/ - echo " done!" - fi - else - cp ${PI_HOLE_LOCAL_REPO}/advanced/index.js /var/www/html/pihole/ - echo " done!" - fi - - echo -n "::: Installing blockingpage.css..." - if [ -f "/var/www/html/pihole/blockingpage.css" ]; then - if [[ ${CUSTOMBLOCKPAGE} == true ]]; then - echo " Existing blockingpage.css detected, not overwriting" - else cp ${PI_HOLE_LOCAL_REPO}/advanced/blockingpage.css /var/www/html/pihole - echo " done!" fi - else - cp ${PI_HOLE_LOCAL_REPO}/advanced/blockingpage.css /var/www/html/pihole - echo " done!" - fi - else echo "::: Creating directory for blocking page" install -d /var/www/html/pihole From 41dd163453cc37a2962a6d5cbf4851f53c74c49b Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 5 May 2017 22:27:33 +0100 Subject: [PATCH 3/8] further simplify --- automated install/basic-install.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index eaa3413d..d603585f 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -872,15 +872,14 @@ installPiholeWeb() { fi # Install the web interface echo ":::" - echo -n "::: Installing index.php..." if [ -d "/var/www/html/pihole" ]; then if [[ ${CUSTOMBLOCKPAGE} == false ]]; then - cp ${PI_HOLE_LOCAL_REPO}/advanced/index.php /var/www/html/pihole/ - cp ${PI_HOLE_LOCAL_REPO}/advanced/index.js /var/www/html/pihole/ - cp ${PI_HOLE_LOCAL_REPO}/advanced/blockingpage.css /var/www/html/pihole + echo -n "::: Installing block page..." + install -D ${PI_HOLE_LOCAL_REPO}/advanced/{index,blockingpage}.* /var/www/html/pihole/ + echo " done!" fi else - echo "::: Creating directory for blocking page" + echo "::: Creating directory for blocking page" install -d /var/www/html/pihole install -D ${PI_HOLE_LOCAL_REPO}/advanced/{index,blockingpage}.* /var/www/html/pihole/ if [ -f /var/www/html/index.lighttpd.html ]; then From 615ca56ea3967e915fb38a660ef9fe336e056126 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 5 May 2017 22:27:58 +0100 Subject: [PATCH 4/8] fix inteliJ IDEA complaints --- 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 d603585f..908902f3 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -875,13 +875,13 @@ installPiholeWeb() { if [ -d "/var/www/html/pihole" ]; then if [[ ${CUSTOMBLOCKPAGE} == false ]]; then echo -n "::: Installing block page..." - install -D ${PI_HOLE_LOCAL_REPO}/advanced/{index,blockingpage}.* /var/www/html/pihole/ + install -D ${PI_HOLE_LOCAL_REPO}/advanced/index.* /advanced/blockingpage.* /var/www/html/pihole/ echo " done!" fi else echo "::: Creating directory for blocking page" install -d /var/www/html/pihole - install -D ${PI_HOLE_LOCAL_REPO}/advanced/{index,blockingpage}.* /var/www/html/pihole/ + install -D ${PI_HOLE_LOCAL_REPO}/advanced/index.* /advanced/blockingpage.* /var/www/html/pihole/ if [ -f /var/www/html/index.lighttpd.html ]; then mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig else From 324d4433c3fc616ba25e9fe58e534e3bfc30e6f6 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 5 May 2017 22:31:31 +0100 Subject: [PATCH 5/8] even further simplify --- automated install/basic-install.sh | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 908902f3..feeb2791 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -872,24 +872,20 @@ installPiholeWeb() { fi # Install the web interface echo ":::" - if [ -d "/var/www/html/pihole" ]; then - if [[ ${CUSTOMBLOCKPAGE} == false ]]; then - echo -n "::: Installing block page..." - install -D ${PI_HOLE_LOCAL_REPO}/advanced/index.* /advanced/blockingpage.* /var/www/html/pihole/ - echo " done!" - fi - else - echo "::: Creating directory for blocking page" + + if [[ ${CUSTOMBLOCKPAGE} == false ]]; then + echo -n "::: Installing block page..." install -d /var/www/html/pihole install -D ${PI_HOLE_LOCAL_REPO}/advanced/index.* /advanced/blockingpage.* /var/www/html/pihole/ - if [ -f /var/www/html/index.lighttpd.html ]; then - mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig - else - printf "\n:::\tNo default index.lighttpd.html file found... not backing up" - fi echo " done!" fi + if [ -f /var/www/html/index.lighttpd.html ]; then + mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig + else + printf "\n:::\tNo default index.lighttpd.html file found... not backing up" + fi + # Install Sudoer file echo ":::" echo -n "::: Installing sudoer file..." From 5b0927ca4b735a9f3b996ec38877df3a0852cf29 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 5 May 2017 22:32:27 +0100 Subject: [PATCH 6/8] tidy up output --- automated install/basic-install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index feeb2791..62130ca6 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -880,10 +880,12 @@ installPiholeWeb() { echo " done!" fi + echo -n "::: Backing up default lighttpd index page..." if [ -f /var/www/html/index.lighttpd.html ]; then mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig + echo " done!" else - printf "\n:::\tNo default index.lighttpd.html file found... not backing up" + echo " No default index.lighttpd.html file found... not backing up" fi # Install Sudoer file From 19fd25c7cd54b3cfc19ded79373869c9d035dbb4 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 5 May 2017 22:40:10 +0100 Subject: [PATCH 7/8] revert line, looks tidyer --- 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 62130ca6..516f8ebf 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -876,7 +876,7 @@ installPiholeWeb() { if [[ ${CUSTOMBLOCKPAGE} == false ]]; then echo -n "::: Installing block page..." install -d /var/www/html/pihole - install -D ${PI_HOLE_LOCAL_REPO}/advanced/index.* /advanced/blockingpage.* /var/www/html/pihole/ + install -D ${PI_HOLE_LOCAL_REPO}/advanced/{index,blockingpage}.* /var/www/html/pihole/ echo " done!" fi From 525a1228c3c999ffc4b0dfd523c0c8b9cf3cb784 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 5 May 2017 22:43:37 +0100 Subject: [PATCH 8/8] clarify --- automated install/basic-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 516f8ebf..df60e59f 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -878,6 +878,8 @@ installPiholeWeb() { install -d /var/www/html/pihole install -D ${PI_HOLE_LOCAL_REPO}/advanced/{index,blockingpage}.* /var/www/html/pihole/ echo " done!" + else + echo "::: Custom block page detected... not overwriting!" fi echo -n "::: Backing up default lighttpd index page..."