Compare commits
1 Commits
v5.1.2
...
fix/optimi
Author | SHA1 | Date | |
---|---|---|---|
|
51fd7a8fc1 |
35
gravity.sh
35
gravity.sh
@@ -702,6 +702,21 @@ gravity_Trap() {
|
|||||||
trap '{ echo -e "\\n\\n ${INFO} ${COL_LIGHT_RED}User-abort detected${COL_NC}"; gravity_Cleanup "error"; }' INT
|
trap '{ echo -e "\\n\\n ${INFO} ${COL_LIGHT_RED}User-abort detected${COL_NC}"; gravity_Cleanup "error"; }' INT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gravity_Optimize() {
|
||||||
|
str="Optimizing domains database"
|
||||||
|
echo -ne " ${INFO} ${str}..."
|
||||||
|
# Run VACUUM command on database to optimize it
|
||||||
|
output=$( { sqlite3 "${gravityDBfile}" "VACUUM;"; } 2>&1 )
|
||||||
|
status="$?"
|
||||||
|
|
||||||
|
if [[ "${status}" -ne 0 ]]; then
|
||||||
|
echo -e "\\n ${CROSS} Unable to optimize gravity database ${gravityDBfile}\\n ${output}"
|
||||||
|
error="error"
|
||||||
|
else
|
||||||
|
echo -e "${OVER} ${TICK} ${str}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Clean up after Gravity upon exit or cancellation
|
# Clean up after Gravity upon exit or cancellation
|
||||||
gravity_Cleanup() {
|
gravity_Cleanup() {
|
||||||
local error="${1:-}"
|
local error="${1:-}"
|
||||||
@@ -728,21 +743,6 @@ gravity_Cleanup() {
|
|||||||
|
|
||||||
echo -e "${OVER} ${TICK} ${str}"
|
echo -e "${OVER} ${TICK} ${str}"
|
||||||
|
|
||||||
if ${optimize_database} ; then
|
|
||||||
str="Optimizing domains database"
|
|
||||||
echo -ne " ${INFO} ${str}..."
|
|
||||||
# Run VACUUM command on database to optimize it
|
|
||||||
output=$( { sqlite3 "${gravityDBfile}" "VACUUM;"; } 2>&1 )
|
|
||||||
status="$?"
|
|
||||||
|
|
||||||
if [[ "${status}" -ne 0 ]]; then
|
|
||||||
echo -e "\\n ${CROSS} Unable to optimize gravity database ${gravityDBfile}\\n ${output}"
|
|
||||||
error="error"
|
|
||||||
else
|
|
||||||
echo -e "${OVER} ${TICK} ${str}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Only restart DNS service if offline
|
# Only restart DNS service if offline
|
||||||
if ! pgrep pihole-FTL &> /dev/null; then
|
if ! pgrep pihole-FTL &> /dev/null; then
|
||||||
"${PIHOLE_COMMAND}" restartdns
|
"${PIHOLE_COMMAND}" restartdns
|
||||||
@@ -819,6 +819,11 @@ chmod g+w "${piholeDir}" "${gravityDBfile}"
|
|||||||
# Compute numbers to be displayed
|
# Compute numbers to be displayed
|
||||||
gravity_ShowCount
|
gravity_ShowCount
|
||||||
|
|
||||||
|
# Optimize gravity database if requested
|
||||||
|
if ${optimize_database} ; then
|
||||||
|
gravity_Optimize
|
||||||
|
fi
|
||||||
|
|
||||||
# Determine if DNS has been restarted by this instance of gravity
|
# Determine if DNS has been restarted by this instance of gravity
|
||||||
if [[ -z "${dnsWasOffline:-}" ]]; then
|
if [[ -z "${dnsWasOffline:-}" ]]; then
|
||||||
"${PIHOLE_COMMAND}" restartdns reload
|
"${PIHOLE_COMMAND}" restartdns reload
|
||||||
|
Reference in New Issue
Block a user