#!/usr/bin/env bash # Created by John A. Hoeven with the ethical assistance of Claude AI # --------------------------------------------------------------------------- # 02_doas.sh # ~/projects/ceos/alpine-installer/lib/base/02_doas.sh # Version: v0.0.1 | Status: DEVELOPMENT # Target: Alpine Linux x86-64 (tinkerpad / ThinkPad T480) # --------------------------------------------------------------------------- # Base Tier subscript: install doas and write /etc/doas.d/wheel.conf. # Defines install_base_doas(). # --------------------------------------------------------------------------- install_base_doas() { log_info "--- base/02_doas: installing doas ---" install_pkg "doas" run_test "doas binary present" 'command -v doas >/dev/null 2>&1' warn log_info "--- base/02_doas: configuring /etc/doas.d/wheel.conf ---" if ! doas test -d /etc/doas.d 2>/dev/null; then doas mkdir -p /etc/doas.d >> "${LOG_FILE}" 2>&1 \ || { log_warn "Could not create /etc/doas.d — skipping wheel.conf"; return 1; } fi if doas test -f /etc/doas.d/wheel.conf 2>/dev/null; then log_info "/etc/doas.d/wheel.conf already present — skipping write" else printf 'permit persist :wheel\n' \ | doas tee /etc/doas.d/wheel.conf > /dev/null 2>&1 \ || log_warn "Failed to write wheel.conf — configure manually: permit persist :wheel" run_test "wheel.conf written" '[[ -s /etc/doas.d/wheel.conf ]]' warn fi log_info "doas configuration complete" } # Standalone entry point if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" SCRIPT_NAME="02_doas" source "${SCRIPT_DIR}/lib/ce-common.sh" || { echo "ERROR: ce-common.sh not found"; exit 1; } check_not_root install_base_doas print_summary fi