Assure that Lighttpd conf-enabled symlink is removed

`/etc/lighttpd/conf-enabled` usually contains symlinks to the actual files in `/etc/lighttpd/conf-available`, at least `lighty-enable-mod` does exactly this. If `/etc/lighttpd/conf-available/15-pihole-admin.conf` is removed first, `/etc/lighttpd/conf-enabled/15-pihole-admin.conf` hence points to nowhere, which makes the `-f` check return false. The orphaned symlink is hence not removed, if `lighty-disable-mod` is not available.

This PR changes the order, to remove the symlink first, and to be failsafe also if it is orphaned already, and the actual config afterwards.

Signed-off-by: MichaIng <micha@dietpi.com>
This commit is contained in:
MichaIng 2025-02-22 23:27:05 +01:00
parent 667a25574a
commit 8e706e4a16
No known key found for this signature in database
GPG Key ID: CE6E5D0C45CE1624
1 changed files with 4 additions and 4 deletions

View File

@ -1208,12 +1208,12 @@ remove_old_pihole_lighttpd_configs() {
lighty-disable-mod pihole-admin >/dev/null || true
fi
if [[ -f "${confavailable}" ]]; then
rm "${confavailable}"
if [[ -f "${confenabled}" || -L "${confenabled}" ]]; then
rm "${confenabled}"
fi
if [[ -f "${confenabled}" ]]; then
rm "${confenabled}"
if [[ -f "${confavailable}" ]]; then
rm "${confavailable}"
fi
}