#!/usr/bin/env sh # keru-install — the Keru OS TUI installer # # Walks you through crafting your exact system, then writes make.conf and # kicks off the build. Everything is swappable here, at install time, and # locked in when you boot. # # Designed to run from the Keru live ISO. Backed by dialog/whiptail if # present; falls back to plain prompted input. All shell, no magic. set -eu . "$(dirname "$0")/../scripts/common.sh" # ---- defaults (mirror profile/make.conf) -------------------------------- OUT="${MAKE_CONF_OUT:-/tmp/keru/make.conf}" DROP="/tmp/keru" mkdir -p "$DROP" # ---- menu helpers ------------------------------------------------------- pick() { # prompt, array-of-labels, defaults -> writes choice to $CHOICE local prompt="$1"; shift local default="$1"; shift CHOICE="$default" if command -v dialog >/dev/null 2>&1; then local args=() local i=0 for opt in "$@"; do args+=("$i" "$opt") i=$((i+1)) done local sel sel=$(dialog --stdout --no-cancel --menu "$prompt" 15 60 8 \ --default-item "$default" "${args[@]}") || true CHOICE=$(eval "printf '%s' \"\${$((sel+1)):-\$default}\"" 2>/dev/null || printf '%s' "$default") else printf '%s\n' "== $prompt ==" local n=1 for opt in "$@"; do printf ' %s) %s\n' "$n" "$opt" n=$((n+1)) done printf 'Select [%s]: ' "$default" read -r sel [ -n "$sel" ] && CHOICE=$(eval "printf '%s' \"\${$sel}\"") || CHOICE="$default" fi } # ---- network check ------------------------------------------------------- # The ISO carries only the installer. Everything else (kernels, init systems, # libcs, filesystems, tools) is fetched and built at install time, so a working # network connection is a hard prerequisite. require_network() { local ok=0 # try a few reachability probes for host in mirror.keru.org github.com 1.1.1.1; do if command -v ping >/dev/null 2>&1 && ping -c1 -W2 "$host" >/dev/null 2>&1; then ok=1; break; fi # fallback: plain connect test via /dev/tcp case "$host" in *.*.*.*) : ;; # ip already covered by ping esac done if [ "$ok" = "0" ]; then if command -v nc >/dev/null 2>&1; then nc -z -w5 mirror.keru.org 443 >/dev/null 2>&1 && ok=1 fi fi [ "$ok" = "1" ] } # ---- network configuration ------------------------------------------------ configure_network() { msg "network configuration" if command -v nmtui >/dev/null 2>&1; then nmtui 2>/dev/null && return 0 fi if command -v dialog >/dev/null 2>&1 && command -v wifi-menu >/dev/null 2>&1; then dialog --stdout --menu "Network" 12 40 3 \ 1 "Wireless (wifi-menu)" 2 "Ethernet (skip)" 3 "Manual (ip)" 2>/dev/null fi read -r -p "Bring up Ethernet (DHCP) now? [Y/n] " eth case "$eth" in n|N|no) : ;; *) command -v dhcpcd >/dev/null 2>&1 && (dhcpcd >/dev/null 2>&1 &) || true ;; esac } banner "Keru OS — network required" info "the ISO only carries the installer." info "the system you choose (init, libc, fs, kernel, tools) is fetched and" info "built from the network during installation. a connection is required." if require_network; then msg "network: connected" else warn "network: not detected" read -r -p "Configure the network now? [Y/n] " cfg case "$cfg" in n|N|no) die "a network connection is required to install Keru" ;; *) configure_network ;; esac require_network || die "still no network connection — cannot install" msg "network: connected" fi # ---- swappable selections ------------------------------------------------ banner "Keru OS — craft your system" pick "Init system" runit runit s6 openrc systemd busybox-init sysvinit dinit shepherd INIT="$CHOICE" pick "C library" glibc glibc musl uclibc-ng LIBC="$CHOICE" pick "Filesystem" ext4 ext4 ext2 ext3 btrfs xfs zfs f2fs jfs reiserfs TARGET_FS="$CHOICE" pick "Kernel" linux linux linux-lts linux-hardened linux-cachyos linux-zen KERNEL="$CHOICE" pick "Privilege elevation (sudo alternative)" doas doas sudo opendoas su SUDO="$CHOICE" pick "Network tools" nmtui nmtui networkmanager connman systemd-networkd NET="$CHOICE" # ---- assemble make.conf ------------------------------------------------ msg "writing $OUT" cat > "$OUT" <