Remove some code from gravity that gets values from setupVars.conf / pihole-FTL.conf - use getFTLConfigValue from utils.sh instead
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
parent
6b1c8a7fff
commit
a91eb48d48
39
gravity.sh
39
gravity.sh
|
@ -13,10 +13,17 @@
|
||||||
|
|
||||||
export LC_ALL=C
|
export LC_ALL=C
|
||||||
|
|
||||||
coltable="/opt/pihole/COL_TABLE"
|
PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
||||||
source "${coltable}"
|
# Source utils.sh for GetFTLConfigValue
|
||||||
|
utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
. "${utilsfile}"
|
||||||
|
|
||||||
|
coltable="${PI_HOLE_SCRIPT_DIR}/COL_TABLE"
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
. "${coltable}"
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
source "/etc/.pihole/advanced/Scripts/database_migration/gravity-db.sh"
|
. "/etc/.pihole/advanced/Scripts/database_migration/gravity-db.sh"
|
||||||
|
|
||||||
basename="pihole"
|
basename="pihole"
|
||||||
PIHOLE_COMMAND="/usr/local/bin/${basename}"
|
PIHOLE_COMMAND="/usr/local/bin/${basename}"
|
||||||
|
@ -33,20 +40,13 @@ localList="${piholeDir}/local.list"
|
||||||
VPNList="/etc/openvpn/ipp.txt"
|
VPNList="/etc/openvpn/ipp.txt"
|
||||||
|
|
||||||
piholeGitDir="/etc/.pihole"
|
piholeGitDir="/etc/.pihole"
|
||||||
gravityDBfile_default="${piholeDir}/gravity.db"
|
GRAVITYDB=$(getFTLConfigValue files.gravity)
|
||||||
# GRAVITYDB may be overwritten by source pihole-FTL.conf below
|
|
||||||
GRAVITYDB="${gravityDBfile_default}"
|
|
||||||
gravityDBschema="${piholeGitDir}/advanced/Templates/gravity.db.sql"
|
gravityDBschema="${piholeGitDir}/advanced/Templates/gravity.db.sql"
|
||||||
gravityDBcopy="${piholeGitDir}/advanced/Templates/gravity_copy.sql"
|
gravityDBcopy="${piholeGitDir}/advanced/Templates/gravity_copy.sql"
|
||||||
|
|
||||||
domainsExtension="domains"
|
domainsExtension="domains"
|
||||||
curl_connect_timeout=10
|
curl_connect_timeout=10
|
||||||
|
|
||||||
# Source setupVars from install script
|
|
||||||
setupVars="${piholeDir}/setupVars.conf"
|
|
||||||
if [[ -f "${setupVars}" ]];then
|
|
||||||
source "${setupVars}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set up tmp dir variable in case it's not configured
|
# Set up tmp dir variable in case it's not configured
|
||||||
: "${GRAVITY_TMPDIR:=/tmp}"
|
: "${GRAVITY_TMPDIR:=/tmp}"
|
||||||
|
@ -56,12 +56,6 @@ if [ ! -d "${GRAVITY_TMPDIR}" ] || [ ! -w "${GRAVITY_TMPDIR}" ]; then
|
||||||
GRAVITY_TMPDIR="/tmp"
|
GRAVITY_TMPDIR="/tmp"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Source pihole-FTL from install script
|
|
||||||
pihole_FTL="${piholeDir}/pihole-FTL.conf"
|
|
||||||
if [[ -f "${pihole_FTL}" ]]; then
|
|
||||||
source "${pihole_FTL}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set this only after sourcing pihole-FTL.conf as the gravity database path may
|
# Set this only after sourcing pihole-FTL.conf as the gravity database path may
|
||||||
# have changed
|
# have changed
|
||||||
gravityDBfile="${GRAVITYDB}"
|
gravityDBfile="${GRAVITYDB}"
|
||||||
|
@ -69,15 +63,6 @@ gravityTEMPfile="${GRAVITYDB}_temp"
|
||||||
gravityDIR="$(dirname -- "${gravityDBfile}")"
|
gravityDIR="$(dirname -- "${gravityDBfile}")"
|
||||||
gravityOLDfile="${gravityDIR}/gravity_old.db"
|
gravityOLDfile="${gravityDIR}/gravity_old.db"
|
||||||
|
|
||||||
if [[ -z "${BLOCKINGMODE}" ]] ; then
|
|
||||||
BLOCKINGMODE="NULL"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Determine if superseded pihole.conf exists
|
|
||||||
if [[ -r "${piholeDir}/pihole.conf" ]]; then
|
|
||||||
echo -e " ${COL_LIGHT_RED}Ignoring overrides specified within pihole.conf! ${COL_NC}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Generate new SQLite3 file from schema template
|
# Generate new SQLite3 file from schema template
|
||||||
generate_gravity_database() {
|
generate_gravity_database() {
|
||||||
if ! pihole-FTL sqlite3 "${gravityDBfile}" < "${gravityDBschema}"; then
|
if ! pihole-FTL sqlite3 "${gravityDBfile}" < "${gravityDBschema}"; then
|
||||||
|
@ -519,7 +504,7 @@ gravity_DownloadBlocklistFromUrl() {
|
||||||
str="Status:"
|
str="Status:"
|
||||||
echo -ne " ${INFO} ${str} Pending..."
|
echo -ne " ${INFO} ${str} Pending..."
|
||||||
blocked=false
|
blocked=false
|
||||||
case $BLOCKINGMODE in
|
case $(getFTLConfigValue dns.blocking.mode) in
|
||||||
"IP-NODATA-AAAA"|"IP")
|
"IP-NODATA-AAAA"|"IP")
|
||||||
# Get IP address of this domain
|
# Get IP address of this domain
|
||||||
ip="$(dig "${domain}" +short)"
|
ip="$(dig "${domain}" +short)"
|
||||||
|
|
Loading…
Reference in New Issue