'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>
28 lines
1.0 KiB
Bash
Executable File
28 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
installSwapfile()
|
|
{
|
|
if [[ "$CFG_REQUIREMENT_SWAPFILE" == "true" ]]; then
|
|
if [ ! -f "$swap_file" ]; then
|
|
isHeader "Increasing Swapfile"
|
|
ISSWAP=$( (runAsManager swapoff /swapfile) 2>&1 )
|
|
if [[ "$ISSWAP" != *"No such file or directory"* ]]; then
|
|
local result; result=$(runAsManager swapoff /swapfile)
|
|
isSuccessful "Turning off /swapfile (if needed)"
|
|
fi
|
|
|
|
local result; result=$(runAsManager fallocate -l $CFG_SWAPFILE_SIZE /swapfile)
|
|
checkSuccess "Allocating $CFG_SWAPFILE_SIZE to the /swapfile"
|
|
|
|
local result; result=$(sudo chmod 0600 /swapfile)
|
|
checkSuccess "Adding permissions to the /swapfile"
|
|
|
|
local result; result=$(runAsManager mkswap /swapfile)
|
|
checkSuccess "Swapping to the new /swapfile"
|
|
|
|
local result; result=$(runAsManager swapon /swapfile)
|
|
checkSuccess "Enabling the new /swapfile"
|
|
fi
|
|
fi
|
|
}
|