ceos-alpine-installer/lib/minimal/11_wiki.sh
John A. Hoeven a194c14077 Add CE OS Alpine installer v0.0.1 — Tier 0/1/2 dev scaffold
Staged installer set for Alpine Linux x86-64 (tinkerpad/ThinkPad T480).
Covers Base (Tier 0), Minimal (Tier 1), and Basic (Tier 2) tiers with
full phased structure, per-package error capture, and re-runnable test suites.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 02:25:38 +02:00

87 lines
3.3 KiB
Bash

#!/usr/bin/env bash
# Created by John A. Hoeven with the ethical assistance of Claude AI
# ---------------------------------------------------------------------------
# 11_wiki.sh
# ~/projects/ceos/alpine-installer/lib/minimal/11_wiki.sh
# Version: v0.0.1 | Status: DEVELOPMENT
# Target: Alpine Linux x86-64 (tinkerpad / ThinkPad T480)
# ---------------------------------------------------------------------------
# Minimal Tier subscript: wiki viewer — glow from CE repo.
# Downloads binary, verifies sha256 and GPG signature, installs to ~/.local/bin/.
# Gracefully skips if CE repo is unreachable or verification fails.
# Defines install_minimal_wiki().
# ---------------------------------------------------------------------------
install_minimal_wiki() {
log_info "--- minimal/11_wiki: glow (CE repo) ---"
local CE_REPO="https://cervelloelettrico.it/bin/amd64/alpine"
local INSTALL_DIR="${HOME}/.local/bin"
local TEMP_DIR
TEMP_DIR="$(mktemp -d /tmp/ce-glow-XXXXXX)"
mkdir -p "${INSTALL_DIR}"
# Abort cleanly if CE repo unreachable
if ! curl --silent --max-time 10 --output /dev/null "${CE_REPO}/glow"; then
log_warn "CE repo unreachable (${CE_REPO}) — skipping glow"
FAILED_PKGS+=("glow (CE repo unreachable)")
rm -rf "${TEMP_DIR}"
return 0
fi
log_info "Downloading glow, sha256, and sig from CE repo..."
local ok=1
curl --silent --max-time 30 -o "${TEMP_DIR}/glow" "${CE_REPO}/glow" || ok=0
curl --silent --max-time 10 -o "${TEMP_DIR}/glow.sha256" "${CE_REPO}/glow.sha256" || ok=0
curl --silent --max-time 10 -o "${TEMP_DIR}/glow.sig" "${CE_REPO}/glow.sig" || ok=0
if [[ "${ok}" -eq 0 ]]; then
log_warn "glow download incomplete — skipping install"
FAILED_PKGS+=("glow (download failed)")
rm -rf "${TEMP_DIR}"
return 0
fi
# SHA256 verification
local expected actual
expected="$(awk '{print $1}' "${TEMP_DIR}/glow.sha256")"
actual="$(sha256sum "${TEMP_DIR}/glow" | awk '{print $1}')"
if [[ "${expected}" != "${actual}" ]]; then
log_warn "glow SHA256 mismatch — aborting (expected: ${expected}, got: ${actual})"
FAILED_PKGS+=("glow (sha256 mismatch)")
rm -rf "${TEMP_DIR}"
return 0
fi
log_info "glow SHA256 verified"
# GPG signature verification (gnupg available from 04_vcs)
if command -v gpg >/dev/null 2>&1; then
if gpg --verify "${TEMP_DIR}/glow.sig" "${TEMP_DIR}/glow" >> "${LOG_FILE}" 2>&1; then
log_info "glow GPG signature verified"
else
log_warn "glow GPG verification failed — aborting install"
FAILED_PKGS+=("glow (gpg verify failed)")
rm -rf "${TEMP_DIR}"
return 0
fi
else
log_warn "gpg not available — proceeding with sha256-only verification"
fi
chmod +x "${TEMP_DIR}/glow"
cp "${TEMP_DIR}/glow" "${INSTALL_DIR}/glow"
rm -rf "${TEMP_DIR}"
run_test "glow installed" 'command -v glow >/dev/null 2>&1' warn
log_info "glow installed to ${INSTALL_DIR}/glow"
}
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
SCRIPT_NAME="11_wiki"
source "${SCRIPT_DIR}/lib/ce-common.sh" || { echo "ERROR: ce-common.sh not found"; exit 1; }
check_not_root
install_minimal_wiki
print_summary
fi