From 8e8c7ecad212d45548dc89f408d2545d332a37a5 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 25 Dec 2023 05:41:43 +0100 Subject: [PATCH] Run gravity upgrade on checkout/update Signed-off-by: DL6ER --- automated install/basic-install.sh | 5 +++++ gravity.sh | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index f5bf15e6..5863e818 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2225,6 +2225,11 @@ main() { # but before starting or restarting the ftl service disable_resolved_stublistener + # Check if gravity database needs to be upgraded. If so, do it without rebuilding + # gravity altogether. This may be a very long running task needlessly blocking + # the update process. + /opt/pihole/gravity.sh --upgrade + printf " %b Restarting services...\\n" "${INFO}" # Start services diff --git a/gravity.sh b/gravity.sh index ebe7e740..216a67a5 100755 --- a/gravity.sh +++ b/gravity.sh @@ -78,7 +78,7 @@ gravity_build_tree() { echo -ne " ${INFO} ${str}..." # The index is intentionally not UNIQUE as poor quality adlists may contain domains more than once - output=$( { time pihole-FTL sqlite3 -ni "${gravityTEMPfile}" "CREATE INDEX idx_gravity ON gravity (domain, adlist_id);"; } ) + output=$( { pihole-FTL sqlite3 -ni "${gravityTEMPfile}" "CREATE INDEX idx_gravity ON gravity (domain, adlist_id);"; } 2>&1 ) status="$?" if [[ "${status}" -ne 0 ]]; then @@ -831,6 +831,7 @@ for var in "$@"; do case "${var}" in "-f" | "--force" ) forceDelete=true;; "-r" | "--repair" ) repairSelector "$3";; + "-u" | "--upgrade" ) upgrade_gravityDB "${gravityDBfile}" "${piholeDir}"; exit 0;; "-h" | "--help" ) helpFunc;; esac done