ceos-alpine-installer/ce-base.sh
John A. Hoeven e4ab10ef56 Apply ceos_install_todo.md fixes
- df -kP: POSIX mode prevents LVM line-wrap false WARNs (all tier scripts)
- 11_wiki: glow from @testing on x86_64; CE repo path kept for ARM
- 12_access: ly from @testing on x86_64+aarch64; MANUAL stub for armhf;
  post-install: rc-update add ly default + comment tty2 getty in inittab
- 05_fonts: nerd-fonts-all from v3.23 stable community (no @edge tag)
- ce-common: add ohiod_address()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 01:32:07 +02:00

77 lines
3.1 KiB
Bash

#!/usr/bin/env bash
# Created by John A. Hoeven with the ethical assistance of Claude AI
# ---------------------------------------------------------------------------
# ce-base.sh
# ~/projects/ceos/alpine-installer/ce-base.sh
# Version: v0.0.1 | Status: DEVELOPMENT
# Target: Alpine Linux x86-64 (tinkerpad / ThinkPad T480)
# ---------------------------------------------------------------------------
# Tier 0 — Base. Prerequisites common to all hardware.
# Standalone-runnable. Sources lib/ce-common.sh and lib/base/*.sh.
# ---------------------------------------------------------------------------
SCRIPT_NAME="ce-base"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/lib/ce-common.sh" \
|| { echo "ERROR: lib/ce-common.sh not found"; exit 1; }
source "${SCRIPT_DIR}/lib/base/01_core.sh" \
|| { log_error "lib/base/01_core.sh not found"; exit 1; }
source "${SCRIPT_DIR}/lib/base/02_doas.sh" \
|| { log_error "lib/base/02_doas.sh not found"; exit 1; }
cleanup() {
local exit_code="${?}"
log_info "Running cleanup..."
doas apk cache clean >> "${LOG_FILE}" 2>&1 || true
doas rm -rf /var/cache/apk/* >> "${LOG_FILE}" 2>&1 || true
log_info "Cleanup complete (exit code: ${exit_code})"
}
trap cleanup EXIT INT TERM HUP
phase_preflight() {
log_info "=== TIER 0: PRE-FLIGHT ==="
check_not_root
run_test "bash >= 4" '[[ "${BASH_VERSINFO[0]}" -ge 4 ]]' fail
run_test "arch detected" '[[ -n "${ARCH}" ]]' fail
run_test "apk available" 'command -v apk >/dev/null 2>&1' fail
run_test "disk >= 500MB" '[[ $(df -kP / | awk "NR==2{print \$4}") -ge 512000 ]]' warn
run_test "internet reachable" \
'curl --silent --max-time 10 --output /dev/null https://dl-cdn.alpinelinux.org' warn
log_info "Arch: ${ARCH}"
log_info "Pre-flight complete"
}
phase_install() {
log_info "=== TIER 0: INSTALL ==="
doas apk update >> "${LOG_FILE}" 2>&1 \
&& doas apk upgrade >> "${LOG_FILE}" 2>&1 \
|| { log_error "apk update/upgrade failed"; exit 1; }
run_test "apk functional post-update" \
'apk search bash 2>/dev/null | grep -q "^bash"' fail
install_base_core
install_base_doas
}
phase_verify() {
log_info "=== TIER 0: VERIFY ==="
run_test "bash present" 'command -v bash >/dev/null 2>&1' warn
run_test "curl present" 'command -v curl >/dev/null 2>&1' warn
run_test "ssh present" 'command -v ssh >/dev/null 2>&1' warn
run_test "doas present" 'command -v doas >/dev/null 2>&1' warn
run_test "doas wheel.conf" '[[ -f /etc/doas.d/wheel.conf ]]' warn
run_test "community repo live" 'grep -q "^[^#].*community" /etc/apk/repositories' warn
log_info "Tier 0 verify complete"
}
log_info "=== CE OS INSTALLER — TIER 0: BASE ==="
log_info "Arch: ${ARCH} | Log: ${LOG_FILE}"
phase_preflight
confirm_proceed
phase_install
phase_verify
print_summary
review_pause "Tier 0 — Base" "${LOG_FILE}"
log_info "=== TIER 0 COMPLETE ==="