'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>
30 lines
1.1 KiB
Bash
Executable File
30 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
backupContainerFilesToTemp()
|
|
{
|
|
local app_name="$1"
|
|
local source_folder="$containers_dir$app_name"
|
|
|
|
temp_backup_folder="temp_$(date +%Y%m%d%H%M%S)_$(tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 6)"
|
|
|
|
local result; result=$(createFolders "loud" $docker_install_user "$temp_backup_folder")
|
|
checkSuccess "Creating temp folder for backing up purposes."
|
|
|
|
if [[ $compose_setup == "default" ]]; then
|
|
local compose_file="docker-compose.yml"
|
|
elif [[ $compose_setup == "app" ]]; then
|
|
local compose_file="docker-compose.$app_name.yml"
|
|
fi
|
|
|
|
local source_filenames=("$app_name.config" "migrate.txt" "$compose_file" ".env")
|
|
# Iterate over the list and call moveFile for each source file
|
|
for source_filename in "${source_filenames[@]}"; do
|
|
source_file="$source_folder/$source_filename"
|
|
target_file="$temp_backup_folder/$source_filename"
|
|
if [ -f "$source_file" ]; then
|
|
moveFile "$source_file" "$target_file"
|
|
checkSuccess "Moving $source_filename to $temp_backup_folder"
|
|
fi
|
|
done
|
|
}
|