mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 10:43:55 +00:00
Merge branch 'development' into updater_rewrite
This commit is contained in:
commit
ef8292d371
8 changed files with 276 additions and 37 deletions
|
@ -61,6 +61,7 @@ SetWebPassword(){
|
|||
echo "WEBPASSWORD=${hash}" >> /etc/pihole/setupVars.conf
|
||||
echo "New password set"
|
||||
else
|
||||
echo "WEBPASSWORD=" >> /etc/pihole/setupVars.conf
|
||||
echo "Password removed"
|
||||
fi
|
||||
|
||||
|
|
133
advanced/blockingpage.css
Normal file
133
advanced/blockingpage.css
Normal file
|
@ -0,0 +1,133 @@
|
|||
/* 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, td { font-family: monospace; padding-left: 15px; }
|
||||
/*body, header { background: #E1E1E1; }*/
|
||||
|
||||
body {
|
||||
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);
|
||||
font: 14px, 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-size: 22px;
|
||||
font-weight: bold;
|
||||
width: 100%;
|
||||
padding: 8px 0;
|
||||
text-indent: 32px;
|
||||
background: url("http://pi.hole/admin/img/logo.svg") left no-repeat;
|
||||
background-size: 30px 22px;
|
||||
}
|
||||
|
||||
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: 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: 4px 4px rgba(0,0,0,0.1);
|
||||
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 a, .mini a { display: table-cell; }
|
||||
.blocked a.safe { width: 100%; }
|
||||
|
||||
/* Types of text */
|
||||
.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; }
|
|
@ -1,7 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<script>window.close();</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
103
advanced/index.php
Normal file
103
advanced/index.php
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
/* Detailed Pi-Hole Block Page: Show "Website Blocked" if user browses to site, but not to image/file requests based on the work of WaLLy3K for DietPi & Pi-Hole */
|
||||
|
||||
$uri = escapeshellcmd($_SERVER['REQUEST_URI']);
|
||||
$serverName = escapeshellcmd($_SERVER['SERVER_NAME']);
|
||||
|
||||
// Retrieve server URI extension (EG: jpg, exe, php)
|
||||
$uriExt = pathinfo($uri, PATHINFO_EXTENSION);
|
||||
|
||||
// Define which URL extensions get rendered as "Website Blocked"
|
||||
$webExt = array('asp', 'htm', 'html', 'php', 'rss', 'xml');
|
||||
|
||||
if(in_array($uriExt, $webExt) || empty($uriExt))
|
||||
{
|
||||
// Requested resource has an extension listed in $webExt
|
||||
// or no extension (index access to some folder incl. the root dir)
|
||||
$showPage = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Something else
|
||||
$showPage = false;
|
||||
}
|
||||
|
||||
// Handle incoming URI types
|
||||
if (!$showPage)
|
||||
{
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<script>window.close();</script></head>
|
||||
<body>
|
||||
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
die();
|
||||
}
|
||||
|
||||
// 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 = "";
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset='UTF-8'/>
|
||||
<title>Website Blocked</title>
|
||||
<link rel='stylesheet' href='http://<?php echo $_SERVER['SERVER_ADDR']; ?>/admin/blockingpage.css'/>
|
||||
<link rel='shortcut icon' href='http://<?php echo $_SERVER['SERVER_ADDR']; ?>/admin/img/favicon.png' type='image/png'/>
|
||||
<meta name='viewport' content='width=device-width,initial-scale=1.0,maximum-scale=1.0, user-scalable=no'/>
|
||||
<meta name='robots' content='noindex,nofollow'/>
|
||||
</head>
|
||||
<body id="body">
|
||||
<header>
|
||||
<h1><a href='/'>Website Blocked</a></h1>
|
||||
</header>
|
||||
<main>
|
||||
<div>Access to the following site has been blocked:<br/>
|
||||
<span class='pre msg'><?php echo $serverName.$uri; ?></span></div>
|
||||
<div>If you have an ongoing use for this website, please ask the owner of the Pi-hole in your network to have it whitelisted.</div>
|
||||
<input id="domain" type="hidden" value="<?php echo $serverName; ?>">
|
||||
<input id="quiet" type="hidden" value="yes">
|
||||
<button id="btnSearch" class="buttons blocked" type="button" style="visibility: hidden;"></button>
|
||||
This page is blocked because it is explicitly contained within the following block list(s):
|
||||
<pre id="output" style="width: 100%; height: 100%;" hidden="true"></pre><br/>
|
||||
<div class='buttons blocked'><a class='safe' href='javascript:history.back()'>Go back</a>
|
||||
</main>
|
||||
<footer>Generated <?php echo date('D g:i A, M d'); ?> by Pi-hole <?php echo $piHoleVersion; ?></footer>
|
||||
<script src="http://<?php echo $_SERVER['SERVER_ADDR']; ?>/admin/js/other/jquery.min.js"></script>
|
||||
<script src="http://<?php echo $_SERVER['SERVER_ADDR']; ?>/admin/js/pihole/queryads.js"></script>
|
||||
<script>
|
||||
function inIframe () {
|
||||
try {
|
||||
return window.self !== window.top;
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to detect if page is loaded within iframe
|
||||
if(inIframe())
|
||||
{
|
||||
// Within iframe
|
||||
// hide content of page
|
||||
$('#body').hide();
|
||||
// remove background
|
||||
document.body.style.backgroundImage = "none";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Query adlists
|
||||
$( "#btnSearch" ).click();
|
||||
}
|
||||
// }
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
@ -78,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
|
||||
|
@ -107,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)
|
||||
|
@ -182,13 +182,13 @@ 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}')
|
||||
}
|
||||
|
||||
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() {
|
||||
|
@ -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
|
||||
|
@ -273,8 +278,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
|
||||
}
|
||||
|
||||
|
||||
|
@ -709,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..."
|
||||
${UPDATE_PKG_CACHE} &> /dev/null
|
||||
echo " done!"
|
||||
fi
|
||||
echo ":::"
|
||||
echo -n "::: Updating local cache of available packages..."
|
||||
${UPDATE_PKG_CACHE} &> /dev/null
|
||||
echo " done!"
|
||||
}
|
||||
|
||||
notify_package_updates_available() {
|
||||
|
@ -776,11 +778,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
|
||||
|
||||
|
@ -792,6 +794,14 @@ installPiholeWeb() {
|
|||
echo " done!"
|
||||
fi
|
||||
|
||||
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/blockingpage.css /var/www/html/admin
|
||||
echo " done!"
|
||||
fi
|
||||
|
||||
else
|
||||
mkdir /var/www/html/pihole
|
||||
if [ -f /var/www/html/index.lighttpd.html ]; then
|
||||
|
|
Loading…
Reference in a new issue