#!/usr/bin/env bash # Created by John A. Hoeven with the ethical assistance of Claude AI # --------------------------------------------------------------------------- # 01_core.sh # ~/projects/ceos/alpine-installer/lib/base/01_core.sh # Version: v0.0.1 | Status: DEVELOPMENT # Target: Alpine Linux x86-64 (tinkerpad / ThinkPad T480) # --------------------------------------------------------------------------- # Base Tier subscript: enable community repo, install core packages, # run setup-utmp. Defines install_base_core(). # --------------------------------------------------------------------------- install_base_core() { log_info "--- base/01_core: enabling community repo ---" if grep -q "^[^#].*community" /etc/apk/repositories 2>/dev/null; then log_info "Community repo already enabled — skipping" else doas sed -i '/^#.*community/s/^#//' /etc/apk/repositories \ >> "${LOG_FILE}" 2>&1 \ || log_warn "Could not uncomment community repo — check /etc/apk/repositories" run_test "community repo enabled" \ 'grep -q "^[^#].*community" /etc/apk/repositories' warn fi log_info "--- base/01_core: verifying core packages available ---" local missing=() for pkg in bash-completion ca-certificates curl openssh tzdata utmps; do apk search "${pkg}" 2>/dev/null | grep -q "^${pkg}" \ || missing+=("${pkg}") done if [[ ${#missing[@]} -gt 0 ]]; then log_warn "Not found in repo search: ${missing[*]} — install may fail" fi log_info "--- base/01_core: installing core packages ---" local -a PKGS=(bash-completion ca-certificates curl openssh tzdata utmps) for pkg in "${PKGS[@]}"; do install_pkg "${pkg}" done log_info "--- base/01_core: running setup-utmp ---" if doas setup-utmp >> "${LOG_FILE}" 2>&1; then log_info "setup-utmp complete" else log_warn "setup-utmp returned non-zero — may already be configured" fi } # Standalone entry point if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" SCRIPT_NAME="01_core" source "${SCRIPT_DIR}/lib/ce-common.sh" || { echo "ERROR: ce-common.sh not found"; exit 1; } check_not_root install_base_core print_summary fi