Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDL6ER <dl6er@dl6er.de>2019-08-22 15:19:51 +0300
committerDL6ER <dl6er@dl6er.de>2019-08-22 15:19:51 +0300
commit1820c2c598a56bce5ae608988ad54632ac7361bf (patch)
tree163ec0bb9777aa22e7329bd319ef5977f43629ad /advanced
parent23b688287f4fdb9c809053880594f894c4cfbfc8 (diff)
parent9f77810ca8bf8708cfaf4bb84a7c3de0e6d6d29e (diff)
Merge branch 'development' into new/whitelist-regex-support
Signed-off-by: DL6ER <dl6er@dl6er.de>
Diffstat (limited to 'advanced')
-rw-r--r--advanced/Scripts/database_migration/gravity-db.sh7
-rwxr-xr-xadvanced/Scripts/piholeDebug.sh32
-rwxr-xr-xadvanced/Scripts/query.sh6
-rwxr-xr-xadvanced/Scripts/webpage.sh5
-rw-r--r--advanced/index.php28
-rw-r--r--advanced/lighttpd.conf.debian2
-rw-r--r--advanced/lighttpd.conf.fedora2
7 files changed, 63 insertions, 19 deletions
diff --git a/advanced/Scripts/database_migration/gravity-db.sh b/advanced/Scripts/database_migration/gravity-db.sh
index f37ce176..a82d0d51 100644
--- a/advanced/Scripts/database_migration/gravity-db.sh
+++ b/advanced/Scripts/database_migration/gravity-db.sh
@@ -11,9 +11,12 @@
# Please see LICENSE file for your rights under this license.
upgrade_gravityDB(){
- local database auditFile version
+ local database piholeDir auditFile version
database="${1}"
- auditFile="${2}"
+ piholeDir="${2}"
+ auditFile="${piholeDir}/auditlog.list"
+
+ # Get database version
version="$(sqlite3 "${database}" "SELECT \"value\" FROM \"info\" WHERE \"property\" = 'version';")"
if [[ "$version" == "1" ]]; then
diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh
index 7ba03a37..c9280f45 100755
--- a/advanced/Scripts/piholeDebug.sh
+++ b/advanced/Scripts/piholeDebug.sh
@@ -94,7 +94,35 @@ PIHOLE_RAW_BLOCKLIST_FILES="${PIHOLE_DIRECTORY}/list.*"
PIHOLE_LOCAL_HOSTS_FILE="${PIHOLE_DIRECTORY}/local.list"
PIHOLE_LOGROTATE_FILE="${PIHOLE_DIRECTORY}/logrotate"
PIHOLE_SETUP_VARS_FILE="${PIHOLE_DIRECTORY}/setupVars.conf"
-PIHOLE_GRAVITY_DB_FILE="${PIHOLE_DIRECTORY}/gravity.db"
+PIHOLE_FTL_CONF_FILE="${PIHOLE_DIRECTORY}/pihole-FTL.conf"
+
+# Read the value of an FTL config key. The value is printed to stdout.
+#
+# Args:
+# 1. The key to read
+# 2. The default if the setting or config does not exist
+get_ftl_conf_value() {
+ local key=$1
+ local default=$2
+ local value
+
+ # Obtain key=... setting from pihole-FTL.conf
+ if [[ -e "$PIHOLE_FTL_CONF_FILE" ]]; then
+ # Constructed to return nothing when
+ # a) the setting is not present in the config file, or
+ # b) the setting is commented out (e.g. "#DBFILE=...")
+ value="$(sed -n -e "s/^\\s*$key=\\s*//p" ${PIHOLE_FTL_CONF_FILE})"
+ fi
+
+ # Test for missing value. Use default value in this case.
+ if [[ -z "$value" ]]; then
+ value="$default"
+ fi
+
+ echo "$value"
+}
+
+PIHOLE_GRAVITY_DB_FILE="$(get_ftl_conf_value "GRAVITYDB" "${PIHOLE_DIRECTORY}/gravity.db")"
PIHOLE_COMMAND="${BIN_DIRECTORY}/pihole"
PIHOLE_COLTABLE_FILE="${BIN_DIRECTORY}/COL_TABLE"
@@ -105,7 +133,7 @@ FTL_PORT="${RUN_DIRECTORY}/pihole-FTL.port"
PIHOLE_LOG="${LOG_DIRECTORY}/pihole.log"
PIHOLE_LOG_GZIPS="${LOG_DIRECTORY}/pihole.log.[0-9].*"
PIHOLE_DEBUG_LOG="${LOG_DIRECTORY}/pihole_debug.log"
-PIHOLE_FTL_LOG="${LOG_DIRECTORY}/pihole-FTL.log"
+PIHOLE_FTL_LOG="$(get_ftl_conf_value "LOGFILE" "${LOG_DIRECTORY}/pihole-FTL.log")"
PIHOLE_WEB_SERVER_ACCESS_LOG_FILE="${WEB_SERVER_LOG_DIRECTORY}/access.log"
PIHOLE_WEB_SERVER_ERROR_LOG_FILE="${WEB_SERVER_LOG_DIRECTORY}/error.log"
diff --git a/advanced/Scripts/query.sh b/advanced/Scripts/query.sh
index 035adaac..f40adfbf 100755
--- a/advanced/Scripts/query.sh
+++ b/advanced/Scripts/query.sh
@@ -115,7 +115,9 @@ scanDatabaseTable() {
wbMatch=true
# Print table name
- echo " ${matchType^} found in ${COL_BOLD}${table^}${COL_NC}"
+ if [[ -z "${blockpage}" ]]; then
+ echo " ${matchType^} found in ${COL_BOLD}${table^}${COL_NC}"
+ fi
# Loop over results and print them
mapfile -t results <<< "${result}"
@@ -160,7 +162,7 @@ scanRegexDatabaseTable() {
# shellcheck disable=SC2001
echo "${str_result}" | sed 's/^/ /'
else
- echo "π Regex ${list}"
+ echo "π .wildcard"
exit 0
fi
fi
diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh
index 227363f0..9db10bda 100755
--- a/advanced/Scripts/webpage.sh
+++ b/advanced/Scripts/webpage.sh
@@ -560,8 +560,7 @@ addAudit()
domains=""
for domain in "$@"
do
- # Insert only the domain here. The date_added field will be
- # filled with its default value (date_added = current timestamp)
+ # Check domain to be added. Only continue if it is valid
validDomain="$(checkDomain "${domain}")"
if [[ -n "${validDomain}" ]]; then
# Put comma in between domains when there is
@@ -574,6 +573,8 @@ addAudit()
domains="${domains}('${domain}')"
fi
done
+ # Insert only the domain here. The date_added field will be
+ # filled with its default value (date_added = current timestamp)
sqlite3 "${gravityDBfile}" "INSERT INTO domain_audit (domain) VALUES ${domains};"
}
diff --git a/advanced/index.php b/advanced/index.php
index 78135e1a..62e45091 100644
--- a/advanced/index.php
+++ b/advanced/index.php
@@ -102,20 +102,30 @@ if ($blocklistglob === array()) {
die("[ERROR] There are no domain lists generated lists within <code>/etc/pihole/</code>! Please update gravity by running <code>pihole -g</code>, or repair Pi-hole using <code>pihole -r</code>.");
}
-// Set location of adlists file
-if (is_file("/etc/pihole/adlists.list")) {
- $adLists = "/etc/pihole/adlists.list";
-} elseif (is_file("/etc/pihole/adlists.default")) {
- $adLists = "/etc/pihole/adlists.default";
+// Get possible non-standard location of FTL's database
+$FTLsettings = parse_ini_file("/etc/pihole/pihole-FTL.conf");
+if (isset($FTLsettings["GRAVITYDB"])) {
+ $gravityDBFile = $FTLsettings["GRAVITYDB"];
} else {
- die("[ERROR] File not found: <code>/etc/pihole/adlists.list</code>");
+ $gravityDBFile = "/etc/pihole/gravity.db";
}
-// Get all URLs starting with "http" or "www" from adlists and re-index array numerically
-$adlistsUrls = array_values(preg_grep("/(^http)|(^www)/i", file($adLists, FILE_IGNORE_NEW_LINES)));
+// Connect to gravity.db
+try {
+ $db = new SQLite3($gravityDBFile, SQLITE3_OPEN_READONLY);
+} catch (Exception $exception) {
+ die("[ERROR]: Failed to connect to gravity.db");
+}
+
+// Get all adlist addresses
+$adlistResults = $db->query("SELECT address FROM vw_adlist");
+$adlistsUrls = array();
+while ($row = $adlistResults->fetchArray()) {
+ array_push($adlistsUrls, $row[0]);
+}
if (empty($adlistsUrls))
- die("[ERROR]: There are no adlist URL's found within <code>$adLists</code>");
+ die("[ERROR]: There are no adlists enabled");
// Get total number of blocklists (Including Whitelist, Blacklist & Wildcard lists)
$adlistsCount = count($adlistsUrls) + 3;
diff --git a/advanced/lighttpd.conf.debian b/advanced/lighttpd.conf.debian
index 47bdbee0..2215bbdb 100644
--- a/advanced/lighttpd.conf.debian
+++ b/advanced/lighttpd.conf.debian
@@ -27,7 +27,7 @@ server.modules = (
)
server.document-root = "/var/www/html"
-server.error-handler-404 = "pihole/index.php"
+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 27bc33cc..4232c90f 100644
--- a/advanced/lighttpd.conf.fedora
+++ b/advanced/lighttpd.conf.fedora
@@ -28,7 +28,7 @@ server.modules = (
)
server.document-root = "/var/www/html"
-server.error-handler-404 = "pihole/index.php"
+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"