Skip to content

Commit acb26cc

Browse files
committed
Move FTL cleanup to dedicated function and include removing the PID if it exists
Use this on both container start and container stop for maximum effect
1 parent 27fc8ac commit acb26cc

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/bash_functions.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ ftl_config() {
149149
setup_web_password
150150
}
151151

152+
ftl_cleanup(){
153+
FTL_PID_FILE="$(getFTLConfigValue files.pid)"
154+
# Cleanup
155+
rm -f /run/pihole/FTL.sock /dev/shm/FTL-* "${FTL_PID_FILE}"
156+
}
157+
152158
migrate_v5_configs() {
153159
# Previously, Pi-hole created a number of files in /etc/dnsmasq.d
154160
# During migration, their content is copied into the new single source of

src/start.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ start() {
5353

5454
echo " [i] pihole-FTL pre-start checks"
5555
# Remove possible leftovers from previous pihole-FTL processes
56-
rm -f /dev/shm/FTL-* 2>/dev/null
57-
rm -f /run/pihole/FTL.sock
56+
ftl_cleanup
5857

5958
fix_capabilities
6059
sh /opt/pihole/pihole-FTL-prestart.sh
@@ -135,6 +134,8 @@ stop() {
135134
FTL_EXIT_CODE=1
136135
fi
137136

137+
ftl_cleanup
138+
138139
echo ""
139140
echo " [i] pihole-FTL exited with status $FTL_EXIT_CODE"
140141
echo ""

0 commit comments

Comments
 (0)