From b246dba7e75a484120739a0eb239a150bdb50bbf Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 4 Dec 2016 21:30:59 +0100 Subject: [PATCH 01/37] Rename index.html to index.php --- advanced/{index.html => index.php} | 0 advanced/lighttpd.conf.debian | 2 +- advanced/lighttpd.conf.fedora | 2 +- automated install/basic-install.sh | 16 ++++++++++------ 4 files changed, 12 insertions(+), 8 deletions(-) rename advanced/{index.html => index.php} (100%) diff --git a/advanced/index.html b/advanced/index.php similarity index 100% rename from advanced/index.html rename to advanced/index.php diff --git a/advanced/lighttpd.conf.debian b/advanced/lighttpd.conf.debian index 15821bc7..01f52a85 100644 --- a/advanced/lighttpd.conf.debian +++ b/advanced/lighttpd.conf.debian @@ -21,7 +21,7 @@ server.modules = ( ) server.document-root = "/var/www/html" -server.error-handler-404 = "pihole/index.html" +server.error-handler-404 = "pihole/index.php" server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) server.errorlog = "/var/log/lighttpd/error.log" server.pid-file = "/var/run/lighttpd.pid" diff --git a/advanced/lighttpd.conf.fedora b/advanced/lighttpd.conf.fedora index 96e1311e..d2af5bd4 100644 --- a/advanced/lighttpd.conf.fedora +++ b/advanced/lighttpd.conf.fedora @@ -22,7 +22,7 @@ server.modules = ( ) server.document-root = "/var/www/html" -server.error-handler-404 = "pihole/index.html" +server.error-handler-404 = "pihole/index.php" server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) server.errorlog = "/var/log/lighttpd/error.log" server.pid-file = "/var/run/lighttpd.pid" diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 33444873..8c7a6b1d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -21,6 +21,7 @@ set -e tmpLog=/tmp/pihole-install.log instalLogLoc=/etc/pihole/install.log setupVars=/etc/pihole/setupVars.conf +lighttpdConfig=/etc/lighttpd/lighttpd.conf webInterfaceGitUrl="https://github.com/pi-hole/AdminLTE.git" webInterfaceDir="/var/www/html/admin" @@ -709,9 +710,9 @@ installConfigs() { mkdir /etc/lighttpd chown "${USER}":root /etc/lighttpd elif [ -f "/etc/lighttpd/lighttpd.conf" ]; then - mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig + mv ${lighttpdConfig} ${lighttpdConfig}.orig fi - cp /etc/.pihole/advanced/${LIGHTTPD_CFG} /etc/lighttpd/lighttpd.conf + cp /etc/.pihole/advanced/${LIGHTTPD_CFG} ${lighttpdConfig} mkdir -p /var/run/lighttpd chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/run/lighttpd mkdir -p /var/cache/lighttpd/compress @@ -825,11 +826,11 @@ installPiholeWeb() { echo ":::" echo "::: Installing pihole custom index page..." if [ -d "/var/www/html/pihole" ]; then - if [ -f "/var/www/html/pihole/index.html" ]; then - echo "::: Existing index.html detected, not overwriting" + if [ -f "/var/www/html/pihole/index.php" ]; then + echo "::: Existing index.php detected, not overwriting" else - echo -n "::: index.html missing, replacing... " - cp /etc/.pihole/advanced/index.html /var/www/html/pihole/ + echo -n "::: index.php missing, replacing... " + cp /etc/.pihole/advanced/index.php /var/www/html/pihole/ echo " done!" fi @@ -955,6 +956,9 @@ accountForRefactor() { sed -i 's/piholeDNS1/PIHOLE_DNS_1/g' ${setupVars} sed -i 's/piholeDNS2/PIHOLE_DNS_2/g' ${setupVars} + # Account for change in lighttpd config file + sed -i 's:pihole/index.html:pihole/index.php:' ${lighttpdConfig} + } updatePihole() { From 6e788668f9f9d63f44585aa54d8522eafc8092c3 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 4 Dec 2016 22:17:08 +0100 Subject: [PATCH 02/37] Updated index.php --- advanced/index.php | 61 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/advanced/index.php b/advanced/index.php index 3a4abe1f..41142633 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -1,7 +1,64 @@ + - - + + + + + + Website Blocked + + + + + + +
+

Website Blocked

+
+
+
Access to the following site has been blocked:
+
+
If you have an ongoing use for this website, please ask to owner of the Pi-Hole in your network to have it whitelisted.
+
+
Generated by Pi-hole
+ + From e7241a989cc95bcf3fca527322128d2d5c07a43b Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 4 Dec 2016 22:20:51 +0100 Subject: [PATCH 03/37] Include CSS file --- advanced/index.css | 212 +++++++++++++++++++++++++++++ advanced/index.php | 4 +- automated install/basic-install.sh | 8 ++ 3 files changed, 222 insertions(+), 2 deletions(-) create mode 100644 advanced/index.css diff --git a/advanced/index.css b/advanced/index.css new file mode 100644 index 00000000..b5fae08e --- /dev/null +++ b/advanced/index.css @@ -0,0 +1,212 @@ +/* CSS Reset */ +html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; } +article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } +body { line-height: 1; } +ol, ul { list-style: none; } +blockquote, q { quotes: none; } +blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } +table { border-collapse: collapse; border-spacing: 0; } +html { height: 100%; overflow-x: hidden; } + +/* General Style */ +a { color: rgba(0,60,120,0.95); text-decoration: none; } /* 1E3C5A */ +a:hover { color: rgba(210,120,0,0.95); transition-duration: .2s; } /* 255, 128, 0 */ +divs a { border-bottom: 1px dashed rgba(30,60,90,0.3); } +b { font-weight: bold; } +i { font-style: italic; } + +footer, .pre, input[type='url'], input[type='text'], .alist, .transparent td { font-family: monospace; } +body, header { background: #E1E1E1; } + +body { + background-image: url('http://firebog.net/bg.png'), -webkit-linear-gradient(top, rgba(220,220,220,0.95), rgba(240,240,240,0.95)); + background-image: url('http://firebog.net/bg.png'), linear-gradient(to bottom, rgba(220,220,220,0.95), rgba(240,240,240,0.95)); + background-attachment: fixed; + color: rgba(64,64,64,0.95); + text-shadow: 0 1px rgba(0,0,0,0.04); + font: 14px Arial, sans-serif; + line-height: 1em; +} + +header { + min-width: 320px; + width: 100%; + text-shadow: 0 1px rgba(255,255,255,0.6); + display: table; + table-layout: fixed; + border: 1px solid rgba(0,0,0,0.25); + border-top-color: rgba(255,255,255,0.85); + border-style: solid none; + background-image: -webkit-linear-gradient(top, rgba(240,240,240,0.95), rgba(220,220,220,0.95)); + background-image: linear-gradient(to bottom, rgba(240,240,240,0.95), rgba(220,220,220,0.95)); + box-shadow: 0 0 1px 1px rgba(0,0,0,0.04); +} + +header h1, header div { + display: table-cell; + color: inherit; + font-weight: bold; + vertical-align: middle; + white-space: nowrap; + overflow: hidden; + box-sizing: border-box; +} + +header h1 { + font: bold 1.6em "Trebuchet MS", sans-serif; + width: 100%; + padding: 8px 0; + text-indent: 32px; + background: url("http://firebog.net/PHV.svg") left no-repeat; +} + +header h1 a, h1 a:hover { color: inherit; } +header .alt { width: 85px; font-size: 0.8em; padding-right: 4px; text-align: right; line-height: 1.25em; } +.active { color: green; } +.inactive { color: red; } + +main { + display: block; + width: 80%; + padding: 8px; + font-size: 1em; + background-color: rgba(255,255,255,0.85); + margin: 8px auto; + box-sizing: border-box; + border: 1px solid rgba(0,0,0,0.25); + box-shadow: 0 0 1px 1px rgba(0,0,0,0.04); + line-height: 1.2em; + border-radius: 8px; +} + +h2 { /* Rgba is shared with .transparent th */ + font: 1.15em sans-serif; + background-color: rgba(255,0,0,0.4); + text-shadow: none; + line-height: 1.1em; + padding-bottom: 1px; + margin-top: 8px; + margin-bottom: 4px; + background: -webkit-linear-gradient(left, rgba(0,0,0,0.25), transparent 80%) no-repeat; + background: linear-gradient(to right, rgba(0,0,0,0.25), transparent 80%) no-repeat; + background-size: 100% 1px; + background-position: 0 17px; +} + +h2:first-child { margin-top: 0; } +h2 ~ *:not(h2) { margin-left: 4px; } +li { padding: 2px 0; } +li::before { content: "\00BB\00a0"; } +li a { position: relative; top: 1px; } /* Center bullet-point arrows */ + +/* Button Style */ +.buttons a, input, .transparent th a { /* Swapped rgba is shared with input[type='url'] */ + display: inline-block; + color: rgba(32,32,32,0.9); + font-weight: bold; + text-align: center; + cursor: pointer; + text-shadow: 0 1px rgba(255,255,255,0.2); + line-height: 0.86em; + font-size: 1em; + padding: 4px 8px; + background: #FAFAFA; + background-image: -webkit-linear-gradient(top, rgba(255,255,255,0.05), rgba(0,0,0,0.05)); + background-image: linear-gradient(to bottom, rgba(255,255,255,0.05), rgba(0,0,0,0.05)); + border: 1px solid rgba(0,0,0,0.25); + border-radius: 4px; + box-shadow: 0 1px 0 rgba(0,0,0,0.04); +} + +.buttons { white-space: nowrap; width: 100%; display: table; } +.mini a { width: 50%; } +a.safe { background-color: rgba(0,220,0,0.5); } +a.warn { background-color: rgba(220,0,0,0.5); } + +.blocked, .toggle, .sourcever, .mini, .addurl a, .editurl a { margin-top: 8px; } +.blocked a, .mini a { display: table-cell; } +.blocked a.safe { width: 100%; } + +.ministatus { text-align: center; } + +input[type='url'], input[type='text'] { /* Swapped rgba is shared with .buttons a */ + font-size: 1.15em; + padding: 2px 4px; + text-align: left; + cursor: text; + width: 100%; + box-sizing: border-box; + background-image: -webkit-linear-gradient(top, rgba(0,0,0,0.05), rgba(255,255,255,0.05)); + background-image: linear-gradient(to bottom, rgba(0,0,0,0.05), rgba(255,255,255,0.05)); +} + +input:focus { + outline: none; + box-shadow: 0 0 0 2px rgba(0,128,240,0.4); + border-radius: 4px; +} + +/* Types of text */ +.pre { white-space: pre; overflow: auto; -webkit-overflow-scrolling: touch; } +.msg { display: block; line-height: 1.2em; font-weight: bold; font-size: 1.15em; margin: 4px 8px 8px 8px; white-space: pre-line; } +.request, .finalresults, .sourcever, .invocation, .parameters, .transparent td, .actionfilecontent, .actionslist { font-size: 0.9em; line-height: 1.2em; } /* "Pre sized" */ + +.request, .finalresults, .parameters, .actionfilecontent, .actionslist { /* Dashed outline for excessive text */ + line-height: 1.2em; + padding: 4px; + border: 1px dashed rgba(0,0,0,0.25); + border-right: 0; + background-image: -webkit-linear-gradient(left, #FFF 70%, rgba(255,255,255,0)); + background-image: linear-gradient(to right, #FFF 70%, rgba(255,255,255,0)); + border-radius: 4px 0 0 4px; +} + +.parameters, .finalresults { /* Small scrollbox for excessive text */ + max-height: 116px; + overflow-y: scroll; + -webkit-overflow-scrolling: touch; +} + +.editactions { font-size: 0.8em; } +.actionslist { margin: 4px 0; } + +/* Matching actions in show-url-info */ +.transparent { width: 100%; margin: 0; } +.transparent th { display: block; box-sizing: border-box; text-align: left; padding: 2px 4px; border-radius: 4px; background-image: -webkit-linear-gradient(left, rgba(0,0,0,0.08), transparent 80%); background-image: linear-gradient(to right, rgba(0,0,0,0.08), transparent 80%); } /* Rgba is shared with h2 */ +.transparent td { margin: 4px; display: block; } +.transparent th a { display: none; position: relative; top: -1px; font-size: 0.75em; padding: 2px 5px 1px 3px; } /* Buttons 0.75 0.86 */ +.transparent tr:first-child a, .transparent tr:nth-last-child(2) a { display: inline-block; } /* Only show buttons for First/Last files */ + +footer { font-size: 0.8em; text-align: center; width: 87%; margin: 4px auto; } + +/* Specific Fixes */ +.alist br:first-child { display: none; } /* Final results is displayed in "pre format", so remove first BR */ +.filter a[href*="show-status"] { margin-left: 12px; } /* Margin for View/Edit on show-status */ + +/* Safari & iOS */ +@media screen and (min-color-index:0) and(-webkit-min-device-pixel-ratio:0) { @media { + ::-webkit-input-placeholder { position: relative; top: 3px; } + .transparent th a { padding: 2px 4px 1px 4px; } + a.safe { background-color: rgba(0,220,0,0.4); } + a.warn { background-color: rgba(220,0,0,0.4); } +}} + +@media only screen and (orientation:portrait) { + main { width: 100%; border-radius: 0; margin: 0; border-style: none; border-bottom-style: solid; } + header h1 { display: block; overflow: auto; -webkit-overflow-scrolling: touch; } + ::-webkit-input-placeholder { top: 2px; } +} + +@media only screen and (min-device-width : 320px) and (max-device-width : 667px) and (orientation : landscape) { + main { width: 100%; border-radius: 0; margin: 0; border-style: none; border-bottom-style: solid; } + h2 { padding-bottom: 2px; } /* Necessary for underline to show */ + main { font-size: 0.6em; } + ul li { font-size: 1.7em; } + ul li a { font-size: 0.6em; } + input[type='url'] { font-size: 1.85em; } + .buttons { font-size: 1.7em; } + .editactions { font-size: 1.3em; } + .request { font-size: 1.5em; } + .transparent th a { font-size: 1.35em; } + ::-webkit-input-placeholder { top: 2px; } +} \ No newline at end of file diff --git a/advanced/index.php b/advanced/index.php index 41142633..fe95782a 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -44,8 +44,8 @@ $piHoleVersion = exec('cd /etc/.pihole/ && git describe --tags --abbrev=0'); Website Blocked - - + + /admin/img/favicon.png' type='image/png'/> diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 8c7a6b1d..f48e78c8 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -842,6 +842,14 @@ installPiholeWeb() { echo " done!" fi + if [ -f "/var/www/html/pihole/index.css" ]; then + echo "::: Existing index.css detected, not overwriting" + else + echo -n "::: index.css missing, replacing... " + cp /etc/.pihole/advanced/index.css /var/www/html/pihole/ + echo " done!" + fi + else mkdir /var/www/html/pihole if [ -f /var/www/html/index.lighttpd.html ]; then From a866c4e388b060cdb8615afd4b57b81f0cf47665 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Dec 2016 10:50:19 +0100 Subject: [PATCH 04/37] Place blockingpage.css (former index.css) unter admin/ so we can load it also from some blocked sub-directories --- advanced/{index.css => blockingpage.css} | 0 automated install/basic-install.sh | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) rename advanced/{index.css => blockingpage.css} (100%) diff --git a/advanced/index.css b/advanced/blockingpage.css similarity index 100% rename from advanced/index.css rename to advanced/blockingpage.css diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index f48e78c8..958b2d1d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -842,11 +842,11 @@ installPiholeWeb() { echo " done!" fi - if [ -f "/var/www/html/pihole/index.css" ]; then - echo "::: Existing index.css detected, not overwriting" + if [ -f "/var/www/html/admin/blockingpage.css" ]; then + echo "::: Existing blockingpage.css detected, not overwriting" else echo -n "::: index.css missing, replacing... " - cp /etc/.pihole/advanced/index.css /var/www/html/pihole/ + cp /etc/.pihole/advanced/blockingpage.css /var/www/html/admin echo " done!" fi From 0f90671241c0ec097be0049989fca3a2dcbd7f10 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Dec 2016 10:51:41 +0100 Subject: [PATCH 05/37] Updated index.php to use CSS file unter admin/ --- advanced/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/index.php b/advanced/index.php index fe95782a..d9755dc2 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -44,7 +44,7 @@ $piHoleVersion = exec('cd /etc/.pihole/ && git describe --tags --abbrev=0'); Website Blocked - + /admin/blockingpage.css'/> /admin/img/favicon.png' type='image/png'/> From 20370d4348fee31d249bca39cc882ddb41ebebba Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Dec 2016 11:26:21 +0100 Subject: [PATCH 06/37] Update CSS file --- advanced/blockingpage.css | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/advanced/blockingpage.css b/advanced/blockingpage.css index b5fae08e..f4451f28 100644 --- a/advanced/blockingpage.css +++ b/advanced/blockingpage.css @@ -15,7 +15,7 @@ divs a { border-bottom: 1px dashed rgba(30,60,90,0.3); } b { font-weight: bold; } i { font-style: italic; } -footer, .pre, input[type='url'], input[type='text'], .alist, .transparent td { font-family: monospace; } +footer, pre, input[type='url'], input[type='text'], .alist, .transparent td { font-family: monospace; } body, header { background: #E1E1E1; } body { @@ -76,7 +76,7 @@ main { border: 1px solid rgba(0,0,0,0.25); box-shadow: 0 0 1px 1px rgba(0,0,0,0.04); line-height: 1.2em; - border-radius: 8px; + border-radius: 8px; } h2 { /* Rgba is shared with .transparent th */ @@ -138,7 +138,7 @@ input[type='url'], input[type='text'] { /* Swapped rgba is shared with .buttons box-sizing: border-box; background-image: -webkit-linear-gradient(top, rgba(0,0,0,0.05), rgba(255,255,255,0.05)); background-image: linear-gradient(to bottom, rgba(0,0,0,0.05), rgba(255,255,255,0.05)); -} +} input:focus { outline: none; @@ -184,7 +184,7 @@ footer { font-size: 0.8em; text-align: center; width: 87%; margin: 4px auto; } .filter a[href*="show-status"] { margin-left: 12px; } /* Margin for View/Edit on show-status */ /* Safari & iOS */ -@media screen and (min-color-index:0) and(-webkit-min-device-pixel-ratio:0) { @media { +@media screen and (min-color-index:0) and(-webkit-min-device-pixel-ratio:0) { @media { ::-webkit-input-placeholder { position: relative; top: 3px; } .transparent th a { padding: 2px 4px 1px 4px; } a.safe { background-color: rgba(0,220,0,0.4); } @@ -197,7 +197,7 @@ footer { font-size: 0.8em; text-align: center; width: 87%; margin: 4px auto; } ::-webkit-input-placeholder { top: 2px; } } -@media only screen and (min-device-width : 320px) and (max-device-width : 667px) and (orientation : landscape) { +@media only screen and (min-device-width : 320px) and (max-device-width : 667px) and (orientation : landscape) { main { width: 100%; border-radius: 0; margin: 0; border-style: none; border-bottom-style: solid; } h2 { padding-bottom: 2px; } /* Necessary for underline to show */ main { font-size: 0.6em; } @@ -209,4 +209,4 @@ footer { font-size: 0.8em; text-align: center; width: 87%; margin: 4px auto; } .request { font-size: 1.5em; } .transparent th a { font-size: 1.35em; } ::-webkit-input-placeholder { top: 2px; } -} \ No newline at end of file +} From fc233fcdd3d74129c02f24ca3295c583e811b0c6 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Dec 2016 12:10:05 +0100 Subject: [PATCH 07/37] Fixed typo --- advanced/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/index.php b/advanced/index.php index d9755dc2..af44cd4f 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -56,7 +56,7 @@ $piHoleVersion = exec('cd /etc/.pihole/ && git describe --tags --abbrev=0');
Access to the following site has been blocked:
-
If you have an ongoing use for this website, please ask to owner of the Pi-Hole in your network to have it whitelisted.
+
If you have an ongoing use for this website, please ask the owner of the Pi-Hole in your network to have it whitelisted.
Generated by Pi-hole
From 3d6b22de6cfeac83ebf781dd5dd207b0852376df Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Dec 2016 12:12:01 +0100 Subject: [PATCH 08/37] Update index.php to include more detailed output --- advanced/index.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/advanced/index.php b/advanced/index.php index af44cd4f..deb902bb 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -39,6 +39,12 @@ if (!$showPage) // Get Pi-Hole version $piHoleVersion = exec('cd /etc/.pihole/ && git describe --tags --abbrev=0'); +// Don't show the URI if it is the root directory +if($uri == "/") +{ + $uri = ""; +} + ?> @@ -57,8 +63,18 @@ $piHoleVersion = exec('cd /etc/.pihole/ && git describe --tags --abbrev=0');
Access to the following site has been blocked:
If you have an ongoing use for this website, please ask the owner of the Pi-Hole in your network to have it whitelisted.
+ + + + This page is blocked because it is explicitly contained within the following block list(s): +
Back to safety
Generated by Pi-hole
+ + + From 0d63cfd6c3ded71effe67475f56f3fc37273081e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Dec 2016 12:34:30 +0100 Subject: [PATCH 09/37] Add 1x1 pixel GIF image. Can apparently be used to trick some of the please-don't-use-adblocker pages as many of them contain code like `if ($('Ad').height() == 0) { prevent access to this page; }` --- advanced/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/advanced/index.php b/advanced/index.php index deb902bb..c51fd71c 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -30,6 +30,7 @@ if (!$showPage) + Date: Mon, 5 Dec 2016 14:39:07 +0100 Subject: [PATCH 10/37] Simplified CSS, removed external contents --- advanced/blockingpage.css | 101 +++++--------------------------------- advanced/index.php | 4 +- 2 files changed, 13 insertions(+), 92 deletions(-) diff --git a/advanced/blockingpage.css b/advanced/blockingpage.css index f4451f28..bb37939d 100644 --- a/advanced/blockingpage.css +++ b/advanced/blockingpage.css @@ -16,15 +16,14 @@ b { font-weight: bold; } i { font-style: italic; } footer, pre, input[type='url'], input[type='text'], .alist, .transparent td { font-family: monospace; } -body, header { background: #E1E1E1; } +/*body, header { background: #E1E1E1; }*/ body { - background-image: url('http://firebog.net/bg.png'), -webkit-linear-gradient(top, rgba(220,220,220,0.95), rgba(240,240,240,0.95)); - background-image: url('http://firebog.net/bg.png'), linear-gradient(to bottom, rgba(220,220,220,0.95), rgba(240,240,240,0.95)); + background-image: -webkit-linear-gradient(top, rgba(240,240,240,0.95), rgba(190,190,190,0.95)); + background-image: linear-gradient(to bottom, rgba(240,240,240,0.95), rgba(190,190,190,0.95)); background-attachment: fixed; color: rgba(64,64,64,0.95); - text-shadow: 0 1px rgba(0,0,0,0.04); - font: 14px Arial, sans-serif; + font: 14px, sans-serif; line-height: 1em; } @@ -53,11 +52,13 @@ header h1, header div { } header h1 { - font: bold 1.6em "Trebuchet MS", sans-serif; + font-size: 22px; + font-weight: bold; width: 100%; padding: 8px 0; text-indent: 32px; - background: url("http://firebog.net/PHV.svg") left no-repeat; + background: url("http://pi.hole/admin/img/logo.svg") left no-repeat; + background-size: 30px 22px; } header h1 a, h1 a:hover { color: inherit; } @@ -68,13 +69,13 @@ header .alt { width: 85px; font-size: 0.8em; padding-right: 4px; text-align: rig main { display: block; width: 80%; - padding: 8px; + padding: 10px; font-size: 1em; background-color: rgba(255,255,255,0.85); margin: 8px auto; box-sizing: border-box; border: 1px solid rgba(0,0,0,0.25); - box-shadow: 0 0 1px 1px rgba(0,0,0,0.04); + box-shadow: 4px 4px rgba(0,0,0,0.1); line-height: 1.2em; border-radius: 8px; } @@ -123,90 +124,10 @@ li a { position: relative; top: 1px; } /* Center bullet-point arrows */ a.safe { background-color: rgba(0,220,0,0.5); } a.warn { background-color: rgba(220,0,0,0.5); } -.blocked, .toggle, .sourcever, .mini, .addurl a, .editurl a { margin-top: 8px; } .blocked a, .mini a { display: table-cell; } .blocked a.safe { width: 100%; } -.ministatus { text-align: center; } - -input[type='url'], input[type='text'] { /* Swapped rgba is shared with .buttons a */ - font-size: 1.15em; - padding: 2px 4px; - text-align: left; - cursor: text; - width: 100%; - box-sizing: border-box; - background-image: -webkit-linear-gradient(top, rgba(0,0,0,0.05), rgba(255,255,255,0.05)); - background-image: linear-gradient(to bottom, rgba(0,0,0,0.05), rgba(255,255,255,0.05)); -} - -input:focus { - outline: none; - box-shadow: 0 0 0 2px rgba(0,128,240,0.4); - border-radius: 4px; -} - /* Types of text */ -.pre { white-space: pre; overflow: auto; -webkit-overflow-scrolling: touch; } -.msg { display: block; line-height: 1.2em; font-weight: bold; font-size: 1.15em; margin: 4px 8px 8px 8px; white-space: pre-line; } -.request, .finalresults, .sourcever, .invocation, .parameters, .transparent td, .actionfilecontent, .actionslist { font-size: 0.9em; line-height: 1.2em; } /* "Pre sized" */ - -.request, .finalresults, .parameters, .actionfilecontent, .actionslist { /* Dashed outline for excessive text */ - line-height: 1.2em; - padding: 4px; - border: 1px dashed rgba(0,0,0,0.25); - border-right: 0; - background-image: -webkit-linear-gradient(left, #FFF 70%, rgba(255,255,255,0)); - background-image: linear-gradient(to right, #FFF 70%, rgba(255,255,255,0)); - border-radius: 4px 0 0 4px; -} - -.parameters, .finalresults { /* Small scrollbox for excessive text */ - max-height: 116px; - overflow-y: scroll; - -webkit-overflow-scrolling: touch; -} - -.editactions { font-size: 0.8em; } -.actionslist { margin: 4px 0; } - -/* Matching actions in show-url-info */ -.transparent { width: 100%; margin: 0; } -.transparent th { display: block; box-sizing: border-box; text-align: left; padding: 2px 4px; border-radius: 4px; background-image: -webkit-linear-gradient(left, rgba(0,0,0,0.08), transparent 80%); background-image: linear-gradient(to right, rgba(0,0,0,0.08), transparent 80%); } /* Rgba is shared with h2 */ -.transparent td { margin: 4px; display: block; } -.transparent th a { display: none; position: relative; top: -1px; font-size: 0.75em; padding: 2px 5px 1px 3px; } /* Buttons 0.75 0.86 */ -.transparent tr:first-child a, .transparent tr:nth-last-child(2) a { display: inline-block; } /* Only show buttons for First/Last files */ +.msg { white-space: pre; overflow: auto; -webkit-overflow-scrolling: touch; display: block; line-height: 1.2em; font-weight: bold; font-size: 1.15em; margin: 4px 8px 8px 8px; white-space: pre-line; } footer { font-size: 0.8em; text-align: center; width: 87%; margin: 4px auto; } - -/* Specific Fixes */ -.alist br:first-child { display: none; } /* Final results is displayed in "pre format", so remove first BR */ -.filter a[href*="show-status"] { margin-left: 12px; } /* Margin for View/Edit on show-status */ - -/* Safari & iOS */ -@media screen and (min-color-index:0) and(-webkit-min-device-pixel-ratio:0) { @media { - ::-webkit-input-placeholder { position: relative; top: 3px; } - .transparent th a { padding: 2px 4px 1px 4px; } - a.safe { background-color: rgba(0,220,0,0.4); } - a.warn { background-color: rgba(220,0,0,0.4); } -}} - -@media only screen and (orientation:portrait) { - main { width: 100%; border-radius: 0; margin: 0; border-style: none; border-bottom-style: solid; } - header h1 { display: block; overflow: auto; -webkit-overflow-scrolling: touch; } - ::-webkit-input-placeholder { top: 2px; } -} - -@media only screen and (min-device-width : 320px) and (max-device-width : 667px) and (orientation : landscape) { - main { width: 100%; border-radius: 0; margin: 0; border-style: none; border-bottom-style: solid; } - h2 { padding-bottom: 2px; } /* Necessary for underline to show */ - main { font-size: 0.6em; } - ul li { font-size: 1.7em; } - ul li a { font-size: 0.6em; } - input[type='url'] { font-size: 1.85em; } - .buttons { font-size: 1.7em; } - .editactions { font-size: 1.3em; } - .request { font-size: 1.5em; } - .transparent th a { font-size: 1.35em; } - ::-webkit-input-placeholder { top: 2px; } -} diff --git a/advanced/index.php b/advanced/index.php index c51fd71c..7df55d78 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -68,8 +68,8 @@ if($uri == "/") This page is blocked because it is explicitly contained within the following block list(s): - -
Back to safety +
+
Go back
Generated by Pi-hole
From ca9321624c5187d23c3fe229d70cfb9e696e3663 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Dec 2016 14:40:48 +0100 Subject: [PATCH 11/37] Added padding for ad list results --- advanced/blockingpage.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/blockingpage.css b/advanced/blockingpage.css index bb37939d..1fdb5f19 100644 --- a/advanced/blockingpage.css +++ b/advanced/blockingpage.css @@ -15,7 +15,7 @@ divs a { border-bottom: 1px dashed rgba(30,60,90,0.3); } b { font-weight: bold; } i { font-style: italic; } -footer, pre, input[type='url'], input[type='text'], .alist, .transparent td { font-family: monospace; } +footer, pre, td { font-family: monospace; padding-left: 15px; } /*body, header { background: #E1E1E1; }*/ body { From 5374f652dd5e44672593b6d83dd9b7dc7bfa95f2 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 6 Dec 2016 08:43:24 +0100 Subject: [PATCH 12/37] No need to modify lighttpd config file, since we overwrite it anyways --- automated install/basic-install.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 958b2d1d..f2e5a9d8 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -964,9 +964,6 @@ accountForRefactor() { sed -i 's/piholeDNS1/PIHOLE_DNS_1/g' ${setupVars} sed -i 's/piholeDNS2/PIHOLE_DNS_2/g' ${setupVars} - # Account for change in lighttpd config file - sed -i 's:pihole/index.html:pihole/index.php:' ${lighttpdConfig} - } updatePihole() { From 480211033d196e0d6322e69480a71c2a0535e920 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 6 Dec 2016 14:05:02 +0100 Subject: [PATCH 13/37] Detect if blocking page is loaded within frame or iframe. If so, hide everything --- advanced/index.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/advanced/index.php b/advanced/index.php index 7df55d78..b9c1f7a9 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -56,7 +56,7 @@ if($uri == "/") - +

Website Blocked

@@ -75,7 +75,25 @@ if($uri == "/") From 75deb0296178ed7dfc7c707938815b3a476b23af Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 6 Dec 2016 14:05:48 +0100 Subject: [PATCH 14/37] Don't query pihole if page is hidden anyhow --- advanced/index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/advanced/index.php b/advanced/index.php index b9c1f7a9..6d48d723 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -91,8 +91,10 @@ if($uri == "/") // set white background document.body.style.backgroundImage = "none"; } - - $( "#btnSearch" ).click(); + else + { + $( "#btnSearch" ).click(); + } // } From 505c9e8979d95abb0cad1fddda500997f3379121 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 6 Dec 2016 14:08:45 +0100 Subject: [PATCH 15/37] Minor change --- advanced/index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/advanced/index.php b/advanced/index.php index 6d48d723..9c7f938b 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -86,13 +86,15 @@ if($uri == "/") // Try to detect if page is loaded within iframe if(inIframe()) { - // Within iframe -> hide page + // Within iframe + // hide content of page $('#body').hide(); - // set white background + // remove background document.body.style.backgroundImage = "none"; } else { + // Query adlists $( "#btnSearch" ).click(); } // } From 3c4a9bba78d4ae078feb6b0ae5e89589c5704250 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 15 Dec 2016 10:38:24 +0100 Subject: [PATCH 16/37] Minor change --- advanced/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/index.php b/advanced/index.php index 9c7f938b..46073867 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -63,7 +63,7 @@ if($uri == "/")
Access to the following site has been blocked:
-
If you have an ongoing use for this website, please ask the owner of the Pi-Hole in your network to have it whitelisted.
+
If you have an ongoing use for this website, please ask the owner of the Pi-hole in your network to have it whitelisted.
From bc8cf1b2d8d2a4edd8500e57ef597e3c9dec3a94 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 22 Dec 2016 19:23:06 +0100 Subject: [PATCH 17/37] Fixed wrong indentation --- 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 ab2bc464..14bf10f7 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -799,7 +799,7 @@ installPiholeWeb() { mkdir /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 + else printf "\n:::\tNo default index.lighttpd.html file found... not backing up" fi cp /etc/.pihole/advanced/index.* /var/www/html/pihole/. From 0276c72fe2bf9ed80cfbe923437d3f282c310bb4 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 24 Dec 2016 15:05:57 +0100 Subject: [PATCH 18/37] replace 'git -C' with long version (see #1009) --- advanced/Scripts/update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 advanced/Scripts/update.sh diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh old mode 100644 new mode 100755 index 10728cd8..929d8a25 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -23,8 +23,8 @@ is_repo() { # Use git to check if directory is currently under VCS, return the value local directory="${1}" - git -C "${directory}" status --short &> /dev/null - return + curdir=$PWD; cd $directory; git status --short &> /dev/null; rc=$?; cd $curdir + return $rc } prep_repo() { From b020010f0daa191b419ae4765c03be851dd017f4 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 24 Dec 2016 15:08:30 +0100 Subject: [PATCH 19/37] Removed some of the &> /dev/null --- advanced/Scripts/update.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 929d8a25..e5fd1526 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -40,22 +40,19 @@ make_repo() { local remoteRepo="${2}" local directory="${1}" - (prep_repo "${directory}" && git clone -q --depth 1 "${remoteRepo}" "${directory}" > /dev/null) + (prep_repo "${directory}" && git clone -q --depth 1 "${remoteRepo}" "${directory}") return } update_repo() { local directory="${1}" - local retVal=0 # Pull the latest commits - # Stash all files not tracked for later retrieval - git -C "${directory}" stash --all --quiet &> /dev/null || ${retVal}=1 + git -C "${directory}" stash --all --quiet # Force a clean working directory for cloning - git -C "${directory}" clean --force -d &> /dev/null || ${retVal}=1 + git -C "${directory}" clean --force -d # Fetch latest changes and apply - git -C "${directory}" pull --quiet &> /dev/null || ${retVal}=1 - return ${retVal} + git -C "${directory}" pull --quiet } getGitFiles() { From c449a1c0e0db0e4d630285fc77e126815fded680 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 24 Dec 2016 15:19:39 +0100 Subject: [PATCH 20/37] Added GitCheckUpdateAvail() --- advanced/Scripts/update.sh | 39 +++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index e5fd1526..8b289227 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -23,7 +23,11 @@ is_repo() { # Use git to check if directory is currently under VCS, return the value local directory="${1}" - curdir=$PWD; cd $directory; git status --short &> /dev/null; rc=$?; cd $curdir + curdir=$PWD; + cd $directory; + git status --short &> /dev/null; + rc=$?; + cd $curdir return $rc } @@ -73,29 +77,42 @@ getGitFiles() { fi } +GitCheckUpdateAvail() { + local directory="${1}" + curdir=$PWD; + cd "${directory}" + + # Fetch latest changes in this repo + git fetch origin + status="$(git status -sb)" + + cd "${curdir}" + + if [[ $status == *"behind"* ]]; then + # Local branch is behind remote branch -> Update + return 1 + else + # Local branch is up-to-date + return 0 + fi +} + main() { local pihole_version_current local pihole_version_latest local web_version_current local web_version_latest - if ! is_repo "${PI_HOLE_FILES_DIR}" || ! is_repo "${ADMIN_INTERFACE_DIR}" ; then #This is unlikely + #This is unlikely + if ! is_repo "${PI_HOLE_FILES_DIR}" || ! is_repo "${ADMIN_INTERFACE_DIR}" ; then echo "::: Critical Error: One or more Pi-Hole repos are missing from system!" echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole" exit 1; fi echo "::: Checking for updates..." - # Checks Pi-hole version string in format vX.X.X - pihole_version_current="$(/usr/local/bin/pihole version --pihole --current)" - pihole_version_latest="$(/usr/local/bin/pihole version --pihole --latest)" - web_version_current="$(/usr/local/bin/pihole version --admin --current)" - web_version_latest="$(/usr/local/bin/pihole version --admin --latest)" - if [[ "${pihole_version_latest}" == "-1" || "${web_version_latest}" == "-1" ]]; then - echo "*** Unable to contact GitHub for latest version. Please try again later, contact support if this continues." - exit 1 - fi + # Logic # If latest versions are blank - we've probably hit Github rate limit (stop running `pihole -up so often!): From 65c35a5530468c604ea9f212aa928fb96fb8e935 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 24 Dec 2016 15:32:25 +0100 Subject: [PATCH 21/37] Use new subroutine to determine if updates are available --- advanced/Scripts/update.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 8b289227..14ca74de 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -86,14 +86,17 @@ GitCheckUpdateAvail() { git fetch origin status="$(git status -sb)" + # Change back to original directory cd "${curdir}" if [[ $status == *"behind"* ]]; then # Local branch is behind remote branch -> Update - return 1 - else - # Local branch is up-to-date return 0 + else + # Local branch is up-to-date or in a situation + # where this updater cannot be used (like on a + # branch that exists only locally) + return 1 fi } @@ -112,7 +115,18 @@ main() { echo "::: Checking for updates..." + if GitCheckUpdateAvail "${PI_HOLE_FILES_DIR}" ; then + core_update=true + echo "Pi-hole Core update available" + fi + if GitCheckUpdateAvail "${ADMIN_INTERFACE_DIR}" ; then + web_update=true + echo "Web Interface update available" + fi + + + exit # Logic # If latest versions are blank - we've probably hit Github rate limit (stop running `pihole -up so often!): From 4632b0f797e3cab7d24ce62e07bdf202e3e25cca Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 24 Dec 2016 15:40:31 +0100 Subject: [PATCH 22/37] Updated updater logic --- advanced/Scripts/update.sh | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 14ca74de..3cbc1d65 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -117,20 +117,21 @@ main() { if GitCheckUpdateAvail "${PI_HOLE_FILES_DIR}" ; then core_update=true - echo "Pi-hole Core update available" + echo "::: Pi-hole Core: update available" + else + core_update=false + echo "::: Pi-hole Core: up to date" fi if GitCheckUpdateAvail "${ADMIN_INTERFACE_DIR}" ; then web_update=true - echo "Web Interface update available" + echo "::: Web Interface: update available" + else + web_update=false + echo "::: Web Interface: up to date" fi - - exit - # Logic - # If latest versions are blank - we've probably hit Github rate limit (stop running `pihole -up so often!): - # Update anyway # If Core up to date AND web up to date: # Do nothing # If Core up to date AND web NOT up to date: @@ -140,46 +141,40 @@ main() { # if Core NOT up to date AND web NOT up to date: # pull pihole repo run install --unattended - if [[ "${pihole_version_current}" == "${pihole_version_latest}" ]] && [[ "${web_version_current}" == "${web_version_latest}" ]]; then - echo ":::" - echo "::: Pi-hole version is $pihole_version_current" - echo "::: Web Admin version is $web_version_current" + if ! ${core_update} && ! ${web_update} ; then echo ":::" echo "::: Everything is up to date!" exit 0 - elif [[ "${pihole_version_current}" == "${pihole_version_latest}" ]] && [[ "${web_version_current}" < "${web_version_latest}" ]]; then + elif ! ${core_update} && ${web_update} ; then echo ":::" echo "::: Pi-hole Web Admin files out of date" getGitFiles "${ADMIN_INTERFACE_DIR}" "${ADMIN_INTERFACE_GIT_URL}" - web_updated=true - - elif [[ "${pihole_version_current}" < "${pihole_version_latest}" ]] && [[ "${web_version_current}" == "${web_version_latest}" ]]; then + elif ${core_update} && ! ${web_update} ; then + echo ":::" echo "::: Pi-hole core files out of date" getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}" /etc/.pihole/automated\ install/basic-install.sh --reconfigure --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1 - core_updated=true - elif [[ "${pihole_version_current}" < "${pihole_version_latest}" ]] && [[ "${web_version_current}" < "${web_version_latest}" ]]; then + elif ${core_update} && ${web_update} ; then + echo ":::" echo "::: Updating Everything" getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}" /etc/.pihole/automated\ install/basic-install.sh --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1 - web_updated=true - core_updated=true else echo "*** Update script has malfunctioned, fallthrough reached. Please contact support" exit 1 fi - if [[ "${web_updated}" == true ]]; then + if [[ "${web_update}" == true ]]; then web_version_current="$(/usr/local/bin/pihole version --admin --current)" echo ":::" echo "::: Web Admin version is now at ${web_version_current}" echo "::: If you had made any changes in '/var/www/html/admin/', they have been stashed using 'git stash'" fi - if [[ "${core_updated}" == true ]]; then + if [[ "${core_update}" == true ]]; then pihole_version_current="$(/usr/local/bin/pihole version --pihole --current)" echo ":::" echo "::: Pi-hole version is now at ${pihole_version_current}" From 15db1ffdd51760ab44f5a52faefd301ef42fd53c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 24 Dec 2016 15:48:43 +0100 Subject: [PATCH 23/37] Remove variables not needed any more --- advanced/Scripts/update.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 3cbc1d65..bd8d6b26 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -102,9 +102,7 @@ GitCheckUpdateAvail() { main() { local pihole_version_current - local pihole_version_latest local web_version_current - local web_version_latest #This is unlikely if ! is_repo "${PI_HOLE_FILES_DIR}" || ! is_repo "${ADMIN_INTERFACE_DIR}" ; then From e647efd47174ee474224d400f7c27d842726b73c Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 24 Dec 2016 11:24:20 -0800 Subject: [PATCH 24/37] Shell script, not javascript Signed-off-by: Dan Schaper --- advanced/Scripts/update.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index bd8d6b26..ae73caa4 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -23,10 +23,10 @@ is_repo() { # Use git to check if directory is currently under VCS, return the value local directory="${1}" - curdir=$PWD; - cd $directory; - git status --short &> /dev/null; - rc=$?; + curdir=$PWD + cd $directory + git status --short &> /dev/null + rc=$? cd $curdir return $rc } From 68c17b26dca9bc3afc3255652bc050ce82146838 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 24 Dec 2016 11:41:42 -0800 Subject: [PATCH 25/37] Bashisms Signed-off-by: Dan Schaper --- advanced/Scripts/update.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index ae73caa4..43210a28 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -22,13 +22,15 @@ readonly PI_HOLE_FILES_DIR="/etc/.pihole" is_repo() { # Use git to check if directory is currently under VCS, return the value local directory="${1}" + local curdir + local rc - curdir=$PWD - cd $directory + curdir="${PWD}" + cd "${directory}" || { echo "Unable to change to ${directory}, exiting."; exit 1; } git status --short &> /dev/null rc=$? - cd $curdir - return $rc + cd "${curdir}" || { echo "Unable to change to ${curdir}, exiting."; exit 1; } + return "${rc}" } prep_repo() { From 3365ef7aaa60595039d85db2ee40e3e9e4b9c535 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 24 Dec 2016 11:54:04 -0800 Subject: [PATCH 26/37] `is_repo()` returns values to caller, silence function. Signed-off-by: Dan Schaper --- advanced/Scripts/update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 43210a28..9f9ea320 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -26,10 +26,10 @@ is_repo() { local rc curdir="${PWD}" - cd "${directory}" || { echo "Unable to change to ${directory}, exiting."; exit 1; } + cd "${directory}" &> /dev/null || return 1 git status --short &> /dev/null rc=$? - cd "${curdir}" || { echo "Unable to change to ${curdir}, exiting."; exit 1; } + cd "${curdir}" &> /dev/null || return 1 return "${rc}" } From c2b8bed3a889f81d2b40e07f189652eaf7ad4f47 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 24 Dec 2016 14:43:57 -0800 Subject: [PATCH 27/37] Get the IP address that is the source for the default route out. Fixes interfaces with multiple IP's assigned getting the wrong IPv4 chosen. 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 0a56b06e..bbebe2f0 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -182,7 +182,7 @@ getGitFiles() { find_IPv4_information() { # Find IP used to route to outside world IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') - IPV4_ADDRESS=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') + IPV4_ADDRESS=$(ip route get 8.8.8.8| awk '{print $7}') IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}') } From 1d608b204a75dd9b59a9fac6789b7b96ef62c27e Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 24 Dec 2016 14:50:50 -0800 Subject: [PATCH 28/37] Only allow UP interfaces to be selected. (DOWN interfaces would have not given IP addresses anyways.) 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 bbebe2f0..ab14f519 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -187,8 +187,8 @@ find_IPv4_information() { } get_available_interfaces() { - # Get available interfaces. Consider only getting UP interfaces in the future, and leaving DOWN interfaces out of list. - availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1 | cut -d'@' -f1) + # Get available UP interfaces. + availableInterfaces=$(ip -o link | grep "state UP" | awk '{print $2}' | cut -d':' -f1 | cut -d'@' -f1) } welcomeDialogs() { From 6ff79835da7ef3c565f159e877b83ca37648c476 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 24 Dec 2016 15:08:39 -0800 Subject: [PATCH 29/37] If only one interface available, don't show whiptail, just use that interface. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index ab14f519..47c4925c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -247,6 +247,11 @@ chooseInterface() { # Loop sentinel variable local firstLoop=1 + if [[ $(echo ${availableInterfaces} | wc -l) -eq 1 ]]; then + PIHOLE_INTERFACE=${availableInterfaces} + return + fi + while read -r line; do mode="OFF" if [[ ${firstLoop} -eq 1 ]]; then From da413834762775e48e20d0f7574a6976a878adc4 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 24 Dec 2016 15:26:05 -0800 Subject: [PATCH 30/37] Check IPv6 to see if the route is reachable, if not, don't use. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 0a56b06e..2be4198c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -273,8 +273,11 @@ chooseInterface() { useIPv6dialog() { # Show the IPv6 address used for blocking - IPV6_ADDRESS=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') - whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$IPV6_ADDRESS will be used to block ads." ${r} ${c} + IPV6_ADDRESS=$(ip -6 route get 2001:4860:4860::8888 | grep -v "unreachable" | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') + + if [[ ! -z "${IPV6_ADDRESS}" ]]; then + whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$IPV6_ADDRESS will be used to block ads." ${r} ${c} + fi } From 5e28e6b9ac66f85f1310b582755eb3ba51973a92 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Dec 2016 01:17:46 +0100 Subject: [PATCH 31/37] Removed remaining git -C --- advanced/Scripts/update.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 9f9ea320..2abbca22 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -52,13 +52,18 @@ make_repo() { update_repo() { local directory="${1}" + local curdir + + curdir="${PWD}" + cd "${directory}" &> /dev/null || return 1 # Pull the latest commits # Stash all files not tracked for later retrieval - git -C "${directory}" stash --all --quiet + git stash --all --quiet # Force a clean working directory for cloning - git -C "${directory}" clean --force -d + git clean --force -d # Fetch latest changes and apply - git -C "${directory}" pull --quiet + git pull --quiet + cd "${curdir}" &> /dev/null || return 1 } getGitFiles() { From e15548cbf5b792ea13cfb7db3aaf62fb28b62fa4 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Dec 2016 01:18:58 +0100 Subject: [PATCH 32/37] Add --quiet to git fetch in GitCheckUpdateAvail() --- advanced/Scripts/update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 2abbca22..a2a5e8dc 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -90,7 +90,7 @@ GitCheckUpdateAvail() { cd "${directory}" # Fetch latest changes in this repo - git fetch origin + git fetch --quiet origin status="$(git status -sb)" # Change back to original directory From a0e0465036eb4fab12851165d97ce709c0e73880 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Dec 2016 17:32:59 +0100 Subject: [PATCH 33/37] Revert "Merge pull request #1018 from pi-hole/diginc-patch-1" This reverts commit ff3c36a7a246d46e3cff5b1b3a89f0288352ce78, reversing changes made to 9355a8ad0e335efd7667d202e07b4d31781c388e. --- advanced/pihole.cron | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/advanced/pihole.cron b/advanced/pihole.cron index cb9965f0..8311acfb 100644 --- a/advanced/pihole.cron +++ b/advanced/pihole.cron @@ -13,15 +13,14 @@ # scripts, any changes made to this file will be overwritten when the softare # is updated or re-installed. Please make any changes to the appropriate crontab # or other cron file snippets. -PATH="$PATH:/usr/local/bin/" # Pi-hole: Update the ad sources once a week on Sunday at 01:59 # Download any updates from the adlists -59 1 * * 7 root pihole updateGravity +59 1 * * 7 root PATH="$PATH:/usr/local/bin/" pihole updateGravity # Pi-hole: Update Pi-hole! Uncomment to enable auto update -#30 2 * * 7 root pihole updatePihole +#30 2 * * 7 root PATH="$PATH:/usr/local/bin/" pihole updatePihole # Pi-hole: Flush the log daily at 00:00 so it doesn't get out of control # Stats will be viewable in the Web interface thanks to the cron job above -00 00 * * * root pihole flush +00 00 * * * root PATH="$PATH:/usr/local/bin/" pihole flush From ca056d32d2c29f90252635b74ece15f14b098bcf Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Dec 2016 21:22:59 +0100 Subject: [PATCH 34/37] Remove git -C --- advanced/Scripts/update.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) mode change 100644 => 100755 advanced/Scripts/update.sh diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh old mode 100644 new mode 100755 index 10728cd8..5459ec04 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -22,9 +22,15 @@ readonly PI_HOLE_FILES_DIR="/etc/.pihole" is_repo() { # Use git to check if directory is currently under VCS, return the value local directory="${1}" + local curdir + local rc - git -C "${directory}" status --short &> /dev/null - return + curdir="${PWD}" + cd "${directory}" &> /dev/null || return 1 + git status --short &> /dev/null + rc=$? + cd "${curdir}" &> /dev/null || return 1 + return $rc } prep_repo() { @@ -46,16 +52,20 @@ make_repo() { update_repo() { local directory="${1}" - local retVal=0 + local curdir # Pull the latest commits + curdir="${PWD}" + cd "${directory}" &> /dev/null || return 1 # Stash all files not tracked for later retrieval - git -C "${directory}" stash --all --quiet &> /dev/null || ${retVal}=1 + git stash --all --quiet &> /dev/null # Force a clean working directory for cloning - git -C "${directory}" clean --force -d &> /dev/null || ${retVal}=1 + git clean --force -d &> /dev/null # Fetch latest changes and apply - git -C "${directory}" pull --quiet &> /dev/null || ${retVal}=1 - return ${retVal} + git pull --quiet &> /dev/null + cd "{$curdir}" &> /dev/null || return 1 + + return } getGitFiles() { From e50947eb58be3e41079085bbe7caff99c00d9347 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Dec 2016 21:26:06 +0100 Subject: [PATCH 35/37] mend --- advanced/Scripts/update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 5459ec04..eb6ccd29 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -63,7 +63,7 @@ update_repo() { git clean --force -d &> /dev/null # Fetch latest changes and apply git pull --quiet &> /dev/null - cd "{$curdir}" &> /dev/null || return 1 + cd "${curdir}" &> /dev/null || return 1 return } From 4eedf8a746c86432bc8bf8be4af42e851843cc71 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Tue, 27 Dec 2016 10:59:24 -0800 Subject: [PATCH 36/37] Always update package cache where we can. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 3bda5b58..ea0d59bf 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -79,7 +79,6 @@ if [[ $(command -v apt-get) ]]; then #Debian Family ############################################# PKG_MANAGER="apt-get" - PKG_CACHE="/var/lib/apt/lists/" UPDATE_PKG_CACHE="${PKG_MANAGER} update" PKG_INSTALL="${PKG_MANAGER} --yes --no-install-recommends install" # grep -c will return 1 retVal on 0 matches, block this throwing the set -e with an OR TRUE @@ -108,8 +107,8 @@ elif [ $(command -v rpm) ]; then else PKG_MANAGER="yum" fi - PKG_CACHE="/var/cache/${PKG_MANAGER}" - UPDATE_PKG_CACHE="${PKG_MANAGER} check-update" + # Fedora and family update cache on every PKG_INSTALL call, no need for a separate update. + UPDATE_PKG_CACHE=":" PKG_INSTALL="${PKG_MANAGER} install -y" PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l" INSTALLER_DEPS=(git iproute net-tools newt procps-ng) @@ -718,19 +717,13 @@ update_pacakge_cache() { #Running apt-get update/upgrade with minimal output can cause some issues with #requiring user input (e.g password for phpmyadmin see #218) - #Check to see if apt-get update has already been run today - #it needs to have been run at least once on new installs! - timestamp=$(stat -c %Y ${PKG_CACHE}) - timestampAsDate=$(date -d @"${timestamp}" "+%b %e") - today=$(date "+%b %e") + #Update package cache on apt based OSes. Do this every time since + #it's quick and packages can be updated at any time. - if [ ! "${today}" == "${timestampAsDate}" ]; then - #update package lists echo ":::" - echo -n "::: ${PKG_MANAGER} update has not been run today. Running now..." + echo -n "::: Updating local cache of available packages..." ${UPDATE_PKG_CACHE} &> /dev/null echo " done!" - fi } notify_package_updates_available() { From a328326e3920e387d1609306dbffc3004a514e44 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Tue, 27 Dec 2016 11:41:07 -0800 Subject: [PATCH 37/37] Formatting Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index ea0d59bf..1638829d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -720,10 +720,10 @@ update_pacakge_cache() { #Update package cache on apt based OSes. Do this every time since #it's quick and packages can be updated at any time. - echo ":::" - echo -n "::: Updating local cache of available packages..." - ${UPDATE_PKG_CACHE} &> /dev/null - echo " done!" + echo ":::" + echo -n "::: Updating local cache of available packages..." + ${UPDATE_PKG_CACHE} &> /dev/null + echo " done!" } notify_package_updates_available() {