LibrePortal/scripts/webui/data/utils/webui_app_log.sh
librelad b7d95f5e95 fix(webui): app-log removal uses runFileOp rm -f so uninstall can't hang
The uninstall branch of webuiUpdateAppLog removed the per-app WebUI log
with a bare `rm`. The log lives in the container data plane and is owned
by the container user, often without a write bit. A bare rm (run as root
via `sudo init.sh uninstall`) prompts interactively for write-protected
files — which hangs an otherwise-unattended deploy: the uninstall phase
of a `full` redeploy stopped dead at "rm: remove write-protected regular
file '.../frontend/logs/apps/<app>.log'?".

Route it through runFileOp rm -f (as the container-data owner, force) to
match the neighbouring uninstall_app.sh and the install branch's
owner-aware createTouch/runFileWrite helpers. No prompt, correct owner.

Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-28 13:46:16 +01:00

34 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
webuiUpdateAppLog()
{
local app_name=$1
local type=$2 # install or uninstall
# Create logs directory if it doesn't exist
local log_dir="${containers_dir}libreportal/frontend/logs"
local apps_dir="${log_dir}/apps"
if [ ! -d "$apps_dir" ]; then
local result=$(createFolders "loud" $sudo_user_name $log_dir $apps_dir)
checkSuccess "Creating frontend logs folder"
fi
local log_file="${apps_dir}/${app_name}.log"
# Handle different log types
if [[ "$type" == "install" ]]; then
# Create WebUI log file if it doesn't exist
if [ ! -f "${log_file}" ]; then
createTouch "$log_file" $sudo_user_name "silent"
echo "=== LibrePortal Installation Started at $(date) ===" | runFileWrite "${log_file}" > /dev/null
fi
elif [[ "$type" == "uninstall" ]]; then
# Remove app log file via runFileOp (as the container-data owner) with
# -f: the log can be write-protected, and a bare rm prompts
# interactively for write-protected files, which hangs an unattended
# deploy (the uninstall phase of a 'full' redeploy).
if [ -f "${log_file}" ]; then
local result=$(runFileOp rm -f "${log_file}")
checkSuccess "Removed ${app_name}.log"
fi
fi
}