mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-24 15:13:42 +00:00
Modify pihole arpflush to stop FTL while performing the action and use the new TOML config values
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
8f24e8aa5f
commit
92b15cf744
1 changed files with 26 additions and 10 deletions
|
@ -15,27 +15,29 @@ 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
|
||||
# Obtain DBFILE=... setting from pihole-FTL.db
|
||||
# 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=...")
|
||||
FTLconf="/etc/pihole/pihole-FTL.conf"
|
||||
if [ -e "$FTLconf" ]; then
|
||||
DBFILE="$(sed -n -e 's/^\s*DBFILE\s*=\s*//p' ${FTLconf})"
|
||||
fi
|
||||
# Test for empty string. Use standard path in this case.
|
||||
DBFILE=$(getFTLConfigValue "files.database")
|
||||
if [ -z "$DBFILE" ]; then
|
||||
DBFILE="/etc/pihole/pihole-FTL.db"
|
||||
fi
|
||||
|
||||
|
||||
flushARP(){
|
||||
local output
|
||||
if [[ "${args[1]}" != "quiet" ]]; then
|
||||
echo -ne " ${INFO} Flushing network table ..."
|
||||
fi
|
||||
|
||||
# Stop FTL to prevent database access
|
||||
if ! output=$(pihole-FTL service stop 2>&1); then
|
||||
echo -e "${OVER} ${CROSS} Failed to stop FTL"
|
||||
echo " Output: ${output}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Truncate network_addresses table in pihole-FTL.db
|
||||
# This needs to be done before we can truncate the network table due to
|
||||
# foreign key constraints
|
||||
|
@ -54,6 +56,20 @@ flushARP(){
|
|||
return 1
|
||||
fi
|
||||
|
||||
# Flush ARP cache of the host
|
||||
if ! output=$(ip -s -s neigh flush all 2>&1); then
|
||||
echo -e "${OVER} ${CROSS} Failed to flush ARP cache"
|
||||
echo " Output: ${output}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Start FTL again
|
||||
if ! output=$(pihole-FTL service restart 2>&1); then
|
||||
echo -e "${OVER} ${CROSS} Failed to restart FTL"
|
||||
echo " Output: ${output}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ "${args[1]}" != "quiet" ]]; then
|
||||
echo -e "${OVER} ${TICK} Flushed network table"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue