aports/testing/pihole/0002-Use-variables-for-path-roots.patch
2025-05-12 19:10:20 +00:00

138 lines
4.6 KiB
Diff

From 4302310f876e57b7e670790030c75c8750f9e4a5 Mon Sep 17 00:00:00 2001
From: Mike Crute <mike@crute.us>
Date: Sat, 10 May 2025 15:55:25 -0700
Subject: [PATCH 2/3] Use variables for path roots
---
advanced/Scripts/list.sh | 7 ++++---
advanced/Scripts/piholeARPTable.sh | 8 +++++---
advanced/Scripts/query.sh | 2 +-
gravity.sh | 10 ++++++----
4 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/pi-hole-6.0.6/advanced/Scripts/list.sh b/pi-hole-6.0.6/advanced/Scripts/list.sh
index 5c57f878..f19c1e26 100755
--- a/pi-hole-6.0.6/advanced/Scripts/list.sh
+++ b/pi-hole-6.0.6/advanced/Scripts/list.sh
@@ -10,6 +10,7 @@
# This file is copyright under the latest version of the EUPL.
# Please see LICENSE file for your rights under this license.
+readonly PI_HOLE_DATA_DIR="/etc/pihole"
readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
readonly utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
source "${utilsfile}"
@@ -20,13 +21,13 @@ source "${apifile}"
# Determine database location
DBFILE=$(getFTLConfigValue "files.database")
if [ -z "$DBFILE" ]; then
- DBFILE="/etc/pihole/pihole-FTL.db"
+ DBFILE="${PI_HOLE_DATA_DIR}/pihole-FTL.db"
fi
# Determine gravity database location
GRAVITYDB=$(getFTLConfigValue "files.gravity")
if [ -z "$GRAVITYDB" ]; then
- GRAVITYDB="/etc/pihole/gravity.db"
+ GRAVITYDB="${PI_HOLE_DATA_DIR}/gravity.db"
fi
addmode=true
@@ -38,7 +39,7 @@ domList=()
typeId=""
comment=""
-colfile="/opt/pihole/COL_TABLE"
+colfile="${PI_HOLE_SCRIPT_DIR}/COL_TABLE"
source ${colfile}
helpFunc() {
diff --git a/pi-hole-6.0.6/advanced/Scripts/piholeARPTable.sh b/pi-hole-6.0.6/advanced/Scripts/piholeARPTable.sh
index f55b1320..369b7fb4 100755
--- a/pi-hole-6.0.6/advanced/Scripts/piholeARPTable.sh
+++ b/pi-hole-6.0.6/advanced/Scripts/piholeARPTable.sh
@@ -10,19 +10,21 @@
# This file is copyright under the latest version of the EUPL.
# Please see LICENSE file for your rights under this license.
-coltable="/opt/pihole/COL_TABLE"
+readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
+readonly PI_HOLE_DATA_DIR="/etc/pihole"
+
+coltable="${PI_HOLE_SCRIPT_DIR}/COL_TABLE"
if [[ -f ${coltable} ]]; then
source ${coltable}
fi
-readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
source "${utilsfile}"
# Determine database location
DBFILE=$(getFTLConfigValue "files.database")
if [ -z "$DBFILE" ]; then
- DBFILE="/etc/pihole/pihole-FTL.db"
+ DBFILE="${PI_HOLE_DATA_DIR}/pihole-FTL.db"
fi
flushARP(){
diff --git a/pi-hole-6.0.6/advanced/Scripts/query.sh b/pi-hole-6.0.6/advanced/Scripts/query.sh
index 3340bdd2..ab7ca123 100755
--- a/pi-hole-6.0.6/advanced/Scripts/query.sh
+++ b/pi-hole-6.0.6/advanced/Scripts/query.sh
@@ -21,7 +21,7 @@ partial="false"
domain=""
# Source color table
-colfile="/opt/pihole/COL_TABLE"
+colfile="${PI_HOLE_INSTALL_DIR}/COL_TABLE"
. "${colfile}"
# Source api functions
diff --git a/pi-hole-6.0.6/gravity.sh b/pi-hole-6.0.6/gravity.sh
index 493f2b15..e0c031f4 100755
--- a/pi-hole-6.0.6/gravity.sh
+++ b/pi-hole-6.0.6/gravity.sh
@@ -14,6 +14,7 @@
export LC_ALL=C
PI_HOLE_SCRIPT_DIR="/opt/pihole"
+PI_HOLE_MIGRATIONS_DIR="/etc/.pihole/advanced/Scripts/database_migration"
# Source utils.sh for GetFTLConfigValue
utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
# shellcheck disable=SC1090
@@ -23,7 +24,7 @@ coltable="${PI_HOLE_SCRIPT_DIR}/COL_TABLE"
# shellcheck disable=SC1090
. "${coltable}"
# shellcheck disable=SC1091
-. "/etc/.pihole/advanced/Scripts/database_migration/gravity-db.sh"
+. "${PI_HOLE_MIGRATIONS_DIR}/gravity-db.sh"
basename="pihole"
PIHOLE_COMMAND="/usr/local/bin/${basename}"
@@ -40,10 +41,11 @@ regexFile="${piholeDir}/regex.list"
adListFile="${piholeDir}/adlists.list"
piholeGitDir="/etc/.pihole"
+piholeSchemaTemplateDir="${piholeGitDir}/advanced/Templates"
GRAVITYDB=$(getFTLConfigValue files.gravity)
GRAVITY_TMPDIR=$(getFTLConfigValue files.gravity_tmp)
-gravityDBschema="${piholeGitDir}/advanced/Templates/gravity.db.sql"
-gravityDBcopy="${piholeGitDir}/advanced/Templates/gravity_copy.sql"
+gravityDBschema="${piholeSchemaTemplateDir}/gravity.db.sql"
+gravityDBcopy="${piholeSchemaTemplateDir}/gravity_copy.sql"
domainsExtension="domains"
curl_connect_timeout=10
@@ -58,7 +60,7 @@ fi
# Set this only after sourcing pihole-FTL.conf as the gravity database path may
# have changed
gravityDBfile="${GRAVITYDB}"
-gravityDBfile_default="/etc/pihole/gravity.db"
+gravityDBfile_default="${piholeDir}/gravity.db"
gravityTEMPfile="${GRAVITYDB}_temp"
gravityDIR="$(dirname -- "${gravityDBfile}")"
gravityOLDfile="${gravityDIR}/gravity_old.db"
--
2.45.2