'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>
55 lines
2.1 KiB
Bash
Executable File
55 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# gitPerformUpdate — the proven, file-level LibrePortal update.
|
|
#
|
|
# Backs up the user's configs/logs, re-clones the repo fresh (gitReset), then
|
|
# restores the configs/logs over the clean checkout, zips a snapshot, prunes
|
|
# old backups, and stops tracking ignored files. This is the historical update
|
|
# body that "worked great" — extracted out of gitFolderResetAndBackup so it can
|
|
# be reused non-interactively by the WebUI updater (webuiRunUpdate) WITHOUT the
|
|
# trailing `exit` the interactive CLI flow relies on.
|
|
#
|
|
# Does NOT exit, restart, or redeploy — the caller decides what happens next.
|
|
gitPerformUpdate()
|
|
{
|
|
isHeader "Updating LibrePortal"
|
|
update_done=false
|
|
|
|
if [ ! -d "$backup_install_dir/$backupFolder" ]; then
|
|
local result; result=$(createFolders "loud" $sudo_user_name "$backup_install_dir/$backupFolder")
|
|
checkSuccess "Create the backup folder"
|
|
fi
|
|
local result; result=$(cd $backup_install_dir)
|
|
checkSuccess "Going into the backup install folder"
|
|
|
|
local result; result=$(copyFolder "$configs_dir" "$backup_install_dir/$backupFolder" "$sudo_user_name")
|
|
checkSuccess "Copy the configs to the backup folder"
|
|
local result; result=$(copyFolder "$logs_dir" "$backup_install_dir/$backupFolder" "$sudo_user_name")
|
|
checkSuccess "Copy the logs to the backup folder"
|
|
|
|
gitReset;
|
|
|
|
local result; result=$(copyFolders "$backup_install_dir/$backupFolder/" "$docker_dir" "$sudo_user_name")
|
|
checkSuccess "Copy the backed up folders back into the installation directory"
|
|
|
|
local result; result=$(runAsManager zip -r "$backup_install_dir/$backupFolder.zip" "$backup_install_dir/$backupFolder")
|
|
checkSuccess "Zipping up the the backup folder for safe keeping"
|
|
|
|
gitCleanInstallBackups;
|
|
|
|
gitUntrackFiles;
|
|
}
|
|
|
|
gitFolderResetAndBackup()
|
|
{
|
|
gitPerformUpdate;
|
|
|
|
isSuccessful "Custom changes have been discarded successfully"
|
|
echo ""
|
|
isNotice "You have updated your version of LibrePortal."
|
|
isNotice "To avoid any issues please rerun the 'libreportal'."
|
|
echo ""
|
|
exit
|
|
update_done=true
|
|
}
|