Enhance first-boot configuration with step enable flags and improved documentation
Add step enable flags to the first-boot configuration, allowing users to control the execution of each step during the initial setup. Update the first-boot script to load these flags from the configuration file, ensuring flexibility in customization. Revise the example configuration file to clarify the default behavior and provide guidance on disabling specific steps. This improves user experience by offering more granular control over the first-boot process.
This commit is contained in:
@@ -25,7 +25,19 @@ SWIOTLB_SIZE="${SWIOTLB_SIZE:-65536}"
|
||||
RETERMINAL_DEVICE="${RETERMINAL_DEVICE:-reTerminal-DM}"
|
||||
RETERMINAL_REPO_URL="${RETERMINAL_REPO_URL:-https://github.com/Seeed-Studio/seeed-linux-dtoverlays}"
|
||||
ONESHOT_SCRIPTS="${ONESHOT_SCRIPTS:-}"
|
||||
# Step enable flags (1 = run, 0 = skip). Default all enabled.
|
||||
|
||||
# --- Load config file first (first found); then defaults apply only to unset vars ---
|
||||
FIRST_BOOT_CONF=""
|
||||
for _f in "$SCRIPT_DIR/first-boot.conf" /tmp/first-boot.conf /etc/cm4-provisioning/first-boot.conf; do
|
||||
if [[ -f "$_f" ]]; then
|
||||
# shellcheck source=first-boot.conf.example
|
||||
set -a && source "$_f" && set +a
|
||||
FIRST_BOOT_CONF="$_f"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Step enable flags (1 = run, 0 = skip). Default all enabled; only set if not already set by config.
|
||||
ENABLE_STEP_01="${ENABLE_STEP_01:-1}"
|
||||
ENABLE_STEP_02="${ENABLE_STEP_02:-1}"
|
||||
ENABLE_STEP_03="${ENABLE_STEP_03:-1}"
|
||||
@@ -40,17 +52,6 @@ ENABLE_STEP_11="${ENABLE_STEP_11:-1}"
|
||||
ENABLE_STEP_12="${ENABLE_STEP_12:-1}"
|
||||
ENABLE_STEP_13="${ENABLE_STEP_13:-1}"
|
||||
|
||||
# --- Load config file (first found) ---
|
||||
FIRST_BOOT_CONF=""
|
||||
for _f in "$SCRIPT_DIR/first-boot.conf" /tmp/first-boot.conf /etc/cm4-provisioning/first-boot.conf; do
|
||||
if [[ -f "$_f" ]]; then
|
||||
# shellcheck source=first-boot.conf.example
|
||||
set -a && source "$_f" && set +a
|
||||
FIRST_BOOT_CONF="$_f"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# --- Derived paths ---
|
||||
PI_HOME="/home/$PI_USER"
|
||||
AUTOSTART="$PI_HOME/.config/autostart"
|
||||
@@ -78,10 +79,14 @@ report_status() {
|
||||
}
|
||||
report_status "started" "First-boot started" "" "" ""
|
||||
|
||||
# --- Helper: run step if enabled ---
|
||||
# --- Helper: run step if enabled (accepts "1" or "0"; strips CR/LF/whitespace) ---
|
||||
run_step() {
|
||||
local n="$1" name="$2" enable_var="ENABLE_STEP_${n}"
|
||||
if [[ "${!enable_var}" == "1" ]]; then
|
||||
local n="$1" name="$2"
|
||||
local enable_var="ENABLE_STEP_${n}" val
|
||||
val="${!enable_var}"
|
||||
val="${val//[^01]/}"
|
||||
val="${val:0:1}"
|
||||
if [[ "$val" == "1" ]]; then
|
||||
log "--- Step $n: $name ---"
|
||||
"step_${n}_${name}" || return $?
|
||||
report_status "running" "Step $n: $name completed" "$n" "$name" ""
|
||||
@@ -311,3 +316,14 @@ run_step 10 cmdline
|
||||
run_step 11 oneshots
|
||||
run_step 12 log_permissions
|
||||
run_step 13 reboot
|
||||
|
||||
# If reboot was disabled, still report done and device IP so the portal shows completion
|
||||
_step13_val="${ENABLE_STEP_13:-1}"
|
||||
_step13_val="${_step13_val//[^01]/}"
|
||||
_step13_val="${_step13_val:0:1}"
|
||||
if [[ "$_step13_val" != "1" ]]; then
|
||||
DEVICE_IP="$(hostname -I 2>/dev/null | awk '{print $1}')"
|
||||
report_status "done" "First-boot complete (reboot disabled)" "13" "reboot" "$DEVICE_IP"
|
||||
log "Device IP: ${DEVICE_IP:-unknown}"
|
||||
log "=== first-boot.sh finished (reboot disabled) ==="
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user