aboutsummaryrefslogtreecommitdiff
path: root/custom
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-01-23 18:02:52 -0600
committerCraig Jennings <c@cjennings.net>2026-01-23 18:02:52 -0600
commitc4979e8c8aec181f2b335c65823f1311815777f5 (patch)
treee9776b2faf63c3595e78f1ea176b67a3e4852227 /custom
parent70fe414c5f3d57567328e3a7ec8e673dccb7f1a1 (diff)
downloadarchangel-c4979e8c8aec181f2b335c65823f1311815777f5.tar.gz
archangel-c4979e8c8aec181f2b335c65823f1311815777f5.zip
Fix set -e compatibility in lib functions
- Replace [[ ]] && error pattern with if/then/fi - Pattern causes exit when condition is false with set -e - Fixed in: common.sh, config.sh, disk.sh, install-archzfs Discovered during VM testing: the && short-circuit returns exit code 1 when condition is false, triggering set -e to abort.
Diffstat (limited to 'custom')
-rwxr-xr-xcustom/install-archzfs16
-rw-r--r--custom/lib/common.sh4
-rw-r--r--custom/lib/config.sh4
-rw-r--r--custom/lib/disk.sh4
4 files changed, 17 insertions, 11 deletions
diff --git a/custom/install-archzfs b/custom/install-archzfs
index 6f098cc..6332286 100755
--- a/custom/install-archzfs
+++ b/custom/install-archzfs
@@ -85,16 +85,16 @@ preflight_checks() {
gather_input() {
if [[ "$UNATTENDED" == true ]]; then
# Validate required config values
- [[ -z "$HOSTNAME" ]] && error "Config missing required: HOSTNAME"
- [[ -z "$TIMEZONE" ]] && error "Config missing required: TIMEZONE"
- [[ "$NO_ENCRYPT" != "yes" && -z "$ZFS_PASSPHRASE" ]] && error "Config missing required: ZFS_PASSPHRASE"
- [[ -z "$ROOT_PASSWORD" ]] && error "Config missing required: ROOT_PASSWORD"
- [[ ${#SELECTED_DISKS[@]} -eq 0 ]] && error "Config missing required: DISKS"
+ if [[ -z "$HOSTNAME" ]]; then error "Config missing required: HOSTNAME"; fi
+ if [[ -z "$TIMEZONE" ]]; then error "Config missing required: TIMEZONE"; fi
+ if [[ "$NO_ENCRYPT" != "yes" && -z "$ZFS_PASSPHRASE" ]]; then error "Config missing required: ZFS_PASSPHRASE"; fi
+ if [[ -z "$ROOT_PASSWORD" ]]; then error "Config missing required: ROOT_PASSWORD"; fi
+ if [[ ${#SELECTED_DISKS[@]} -eq 0 ]]; then error "Config missing required: DISKS"; fi
# Set defaults for optional values
- [[ -z "$LOCALE" ]] && LOCALE="en_US.UTF-8"
- [[ -z "$KEYMAP" ]] && KEYMAP="us"
- [[ -z "$ENABLE_SSH" ]] && ENABLE_SSH="yes"
+ [[ -z "$LOCALE" ]] && LOCALE="en_US.UTF-8" || true
+ [[ -z "$KEYMAP" ]] && KEYMAP="us" || true
+ [[ -z "$ENABLE_SSH" ]] && ENABLE_SSH="yes" || true
# Determine RAID level if not specified
if [[ -z "$RAID_LEVEL" && ${#SELECTED_DISKS[@]} -gt 1 ]]; then
diff --git a/custom/lib/common.sh b/custom/lib/common.sh
index a41441d..2f8844e 100644
--- a/custom/lib/common.sh
+++ b/custom/lib/common.sh
@@ -42,7 +42,9 @@ log() {
#############################
require_root() {
- [[ $EUID -ne 0 ]] && error "This script must be run as root"
+ if [[ $EUID -ne 0 ]]; then
+ error "This script must be run as root"
+ fi
}
command_exists() {
diff --git a/custom/lib/config.sh b/custom/lib/config.sh
index 82f5d77..cec3d8c 100644
--- a/custom/lib/config.sh
+++ b/custom/lib/config.sh
@@ -122,6 +122,8 @@ validate_config() {
((errors++))
fi
- [[ $errors -gt 0 ]] && error "Config validation failed with $errors error(s)"
+ if [[ $errors -gt 0 ]]; then
+ error "Config validation failed with $errors error(s)"
+ fi
info "Config validation passed"
}
diff --git a/custom/lib/disk.sh b/custom/lib/disk.sh
index ea8c402..fa3dbd2 100644
--- a/custom/lib/disk.sh
+++ b/custom/lib/disk.sh
@@ -148,7 +148,9 @@ select_disks() {
read -rp "Enter disk path(s) separated by space: " selected
fi
- [[ -z "$selected" ]] && error "No disk selected"
+ if [[ -z "$selected" ]]; then
+ error "No disk selected"
+ fi
# Extract just the device paths (remove size/model info)
SELECTED_DISKS=()