Compare commits

..

No commits in common. "8fd797bf3c4cde903ed86485470fc84f268ee6bf" and "a45f2eacd498316f74e7bd8c780f06b33fe0b5e8" have entirely different histories.

3 changed files with 31 additions and 68 deletions

View File

@ -57,7 +57,7 @@ readonly RAW_BASE="https://gitea.nevim42.cz/nevim42/engram-boot/raw/branch/main"
readonly ENGRAM_REPO="git@gitea.nevim42.cz:nevim42/engram.git"
readonly ENGRAM_DIR="$HOME/Repositories/engram"
readonly KNOWN_HOST="gitea.nevim42.cz"
readonly DEPS=(age git gnupg openssh)
readonly DEPS=(age git gnupg)
WORK=""
CHOSEN_KEYS=()
@ -135,49 +135,31 @@ install_keys() {
local available=()
mapfile -t available < <(find "$WORK/plain/ssh" -maxdepth 1 -type f \
! -name '.*' ! -name '*.pub' ! -name 'known_hosts*' -printf '%f\n' | sort)
! -name '*.pub' ! -name 'known_hosts*' -printf '%f\n' | sort)
if (( ${#available[@]} == 0 )); then
die "No SSH keys found in the bundle."
fi
info "Available keys:"
local i
for i in "${!available[@]}"; do
printf ' %d) %s\n' "$((i + 1))" "${available[$i]}"
done
info "Available keys: ${available[*]}"
local answer
read -rp " Which keys? (numbers, first one becomes id_ed25519, empty = none): " answer
read -rp " Install which keys? (space separated, empty = none): " answer
read -ra CHOSEN_KEYS <<< "$answer"
local num n name target
n=0
for num in $answer; do
if [[ ! $num =~ ^[0-9]+$ ]] || (( num < 1 || num > ${#available[@]} )); then
die "Not a valid key number: $num"
local name
for name in "${CHOSEN_KEYS[@]}"; do
if [[ ! -f "$WORK/plain/ssh/$name" ]]; then
die "Unknown key: $name"
fi
name="${available[$((num - 1))]}"
n=$((n + 1))
# The first chosen key becomes the standard default identity,
# anything after that keeps its own name.
if (( n == 1 )); then
target="id_ed25519"
else
target="$name"
fi
if [[ -e "$HOME/.ssh/$target" ]]; then
warn "$target already exists in ~/.ssh - skipping"
if [[ -e "$HOME/.ssh/$name" ]]; then
warn "$name already exists in ~/.ssh - skipping"
continue
fi
install -m 600 "$WORK/plain/ssh/$name" "$HOME/.ssh/$target"
install -m 600 "$WORK/plain/ssh/$name" "$HOME/.ssh/$name"
if [[ -f "$WORK/plain/ssh/$name.pub" ]]; then
install -m 644 "$WORK/plain/ssh/$name.pub" "$HOME/.ssh/$target.pub"
install -m 644 "$WORK/plain/ssh/$name.pub" "$HOME/.ssh/$name.pub"
fi
CHOSEN_KEYS+=("$name")
info "Installed $name as ~/.ssh/$target"
info "Installed $HOME/.ssh/$name"
done
}
@ -234,17 +216,25 @@ clone_engram() {
return
fi
if [[ ! -f "$HOME/.ssh/id_ed25519" ]]; then
warn "No default key (~/.ssh/id_ed25519) - cannot clone."
if (( ${#CHOSEN_KEYS[@]} == 0 )); then
warn "No SSH key was installed - cannot clone."
return
fi
mkdir -p "$(dirname "$ENGRAM_DIR")"
if ! git clone "$ENGRAM_REPO" "$ENGRAM_DIR"; then
local key
for key in "${CHOSEN_KEYS[@]}"; do
info "Trying key: $key"
if GIT_SSH_COMMAND="ssh -o IdentitiesOnly=yes -i $HOME/.ssh/$key" \
git clone "$ENGRAM_REPO" "$ENGRAM_DIR"; then
info "Cloned into $ENGRAM_DIR (key: $key)"
return
fi
rm -rf "$ENGRAM_DIR"
die "Clone failed - is the deploy key set up on gitea?"
fi
info "Cloned into $ENGRAM_DIR"
done
die "Clone failed with every key - check the deploy key setup on gitea."
}
# ---------------------------------------------------------------------------

View File

@ -16,7 +16,7 @@
# bash install.sh
#
# Flow: checks -> questions -> partition -> LUKS -> BTRFS -> pacstrap ->
# fstab -> chroot setup -> GRUB -> bootstrap.sh -> reboot
# fstab -> chroot setup -> GRUB -> reboot
#
set -euo pipefail
@ -77,7 +77,6 @@ readonly PACSTRAP_PACKAGES=(
wpa_supplicant wget neovim tmux
)
readonly HOOKS_ENCRYPTED="base systemd autodetect microcode modconf kms keyboard sd-vconsole block sd-encrypt filesystems fsck"
readonly RAW_BASE="https://gitea.nevim42.cz/nevim42/engram-boot/raw/branch/main"
# Filled in by ask_questions.
TARGET_DISK=""
@ -355,30 +354,6 @@ CHROOT
rm -f /mnt/root/engram-setup.sh
}
# ---------------------------------------------------------------------------
# bootstrap.sh - drop it into the new home, so the next step is one command.
# ---------------------------------------------------------------------------
fetch() {
if command -v curl >/dev/null; then
curl -fsSL "$1"
else
wget -qO- "$1"
fi
}
place_bootstrap() {
step "Dropping bootstrap.sh into /home/${USER_NAME}"
fetch "$RAW_BASE/bootstrap.sh" > "/mnt/home/${USER_NAME}/bootstrap.sh" \
|| die "Could not fetch bootstrap.sh from $RAW_BASE"
# A fresh system has exactly one user, so uid/gid 1000 is safe.
chown 1000:1000 "/mnt/home/${USER_NAME}/bootstrap.sh"
chmod +x "/mnt/home/${USER_NAME}/bootstrap.sh"
info "Waiting in the new home - no download needed after reboot."
}
# ---------------------------------------------------------------------------
# The exit - summary and reboot.
# ---------------------------------------------------------------------------
@ -393,7 +368,7 @@ finish() {
encrypted : ${ENCRYPTED}
SUMMARY
info "Reboot and log in as ${USER_NAME} - run ~/bootstrap.sh, your engram is waiting."
info "Reboot, log in as ${USER_NAME} and run the bootstrap - your engram is waiting."
local answer
read -rp " Reboot now? [y/N]: " answer
@ -430,7 +405,6 @@ main() {
pacstrap_base
generate_fstab
configure_system
place_bootstrap
finish
}

View File

@ -9,8 +9,7 @@ master key to all of it, so keep it outside this repo.
- `ssh/nevim42-desktop`, `ssh/nevim42-mikoshi`, ... - SSH private keys named
after machines (+ their `.pub`; `nevim42-mikoshi.pub` is registered as a
read-only deploy key on the engram repo). The bootstrap installs your first
chosen key as the standard `~/.ssh/id_ed25519`.
read-only deploy key on the engram repo)
- `ssh/known_hosts.gitea` - pinned gitea host key, no TOFU on first connect
- `gpg/nevim42.asc` - armored export of the GPG secret key