#!/usr/bin/env bash # ───────────────────────────────────────────────────────────────────────────── # Arcline OS — scripted installer # # scripts/install.sh [--edition server] [--boot bios|efi] # [--rootfs | --image ] # # Installs an Arcline OS rootfs onto a real disk: # # sudo scripts/install.sh /dev/sda --edition server # sudo scripts/install.sh /dev/nvme0n1 --edition cloud --image build/artifacts/arcline-cloud-0.1.0-amd64.tar.xz # # WARNING: this WIPES . You are asked to confirm the exact device path # before anything is written. # ───────────────────────────────────────────────────────────────────────────── set -euo pipefail source "$(dirname "${BASH_SOURCE[0]}")/common.sh" DEV="${1:?usage: install.sh [--edition server] [--boot bios|efi] [--rootfs |--image ]}" EDITION="server" BOOT="${BOOT:-bios}" # default from the BOOT build variable (see versions.mk) ROOTFS_SRC="" shift || true while [[ $# -gt 0 ]]; do case "$1" in --edition) EDITION="${2:?}"; shift 2 ;; --boot) BOOT="${2:?}"; shift 2 ;; --rootfs) ROOTFS_SRC="${2:?}"; shift 2 ;; --image) ROOTFS_SRC="${2:?}"; shift 2 ;; *) die "unknown option '$1'" ;; esac done require_root "$0" "$@" validate_edition "$EDITION" [[ "$BOOT" == "bios" || "$BOOT" == "efi" ]] || die "--boot must be bios|efi" [[ -b "$DEV" ]] || die "'$DEV' is not a block device — refusing to install" # ── resolve rootfs (dir or tarball) ───────────────────────────────────────── TMPROOT="" if [[ -n "$ROOTFS_SRC" ]]; then if [[ -d "$ROOTFS_SRC" ]]; then ROOTFS="$ROOTFS_SRC" elif [[ -f "$ROOTFS_SRC" ]]; then TMPROOT="$(mktemp -d /run/arcline-install.XXXXXX)" log "extracting rootfs image: $ROOTFS_SRC" tar -xJf "$ROOTFS_SRC" -C "$TMPROOT" ROOTFS="$TMPROOT" else die "rootfs source '$ROOTFS_SRC' not found" fi else ROOTFS="$ROOTFS_DIR/$EDITION" [[ -d "$ROOTFS" ]] || die "no rootfs for '$EDITION' at $ROOTFS (build it: make rootfs-$EDITION, or pass --rootfs/--image)" fi trap '[[ -n "$TMPROOT" ]] && { rm -rf "$TMPROOT"; }' EXIT # ── safety confirmation ───────────────────────────────────────────────────── echo echo "Arcline OS installer" echo " target device : $DEV" echo " edition : $EDITION" echo " boot : $BOOT" echo echo "!!! ALL DATA ON $DEV WILL BE DESTROYED !!!" read -r -p "Type the device path to confirm ($DEV): " CONFIRM [[ "$CONFIRM" == "$DEV" ]] || die "confirmation mismatch — aborting" "$ROOT/scripts/deploy-disk.sh" "$DEV" "$ROOTFS" "$EDITION" --boot "$BOOT" echo log "install complete. Remove the installation media and reboot." log "After reboot: set a root password and enroll your ssh key" log " sudo passwd root"