'local result=$(cmd)' resets $? to 0 (the local builtin's own exit), so the
following checkSuccess always saw success regardless of cmd's real exit — the
mechanism that masked the de-sudo write failures. Split declaration from
assignment ('local result; result=$(cmd)') across all 235 active-code sites
(84 files) so the command's exit reaches checkSuccess. No behaviour change
beyond $? now being accurate (no set -e in runtime code; multi-line
assignments transform safely).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
34 lines
1.3 KiB
Bash
Executable File
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; 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; result=$(runFileOp rm -f "${log_file}")
|
|
checkSuccess "Removed ${app_name}.log"
|
|
fi
|
|
fi
|
|
} |