aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / scripts / ck_imac_netboot_push.sh
| 1 | #!/usr/bin/env bash |
| 2 | # ck_imac_netboot_push.sh -- sign an iMac kernel image and queue it for NETLDR.EFI |
| 3 | # (native/boot/net_loader.c). The next time the iMac's loader asks (at power-on, |
| 4 | # or within seconds while it waits), the server (ck_imac_netboot serve) offers |
| 5 | # this job; the loader starts it only if the signature and SHA-512 verify. |
| 6 | # |
| 7 | # scripts/ck_imac_netboot_push.sh IMAGE.EFI [KEY] [SPOOL] |
| 8 | # |
| 9 | # KEY lab signing key, 32-byte seed, mode 0600 (default ~/.config/aienos/imac-netboot.key; |
| 10 | # make it once with: ck_imac_netboot keygen KEY PUB) |
| 11 | # SPOOL the server's spool directory (default ~/.local/state/aienos/imac-netboot) |
| 12 | # Steps: ck_slot_tool make-manifest (generation = unix time, commit = HEAD) -> tbs -> |
| 13 | # ck_imac_netboot sign -> ck_slot_tool attach-sig (which verifies the signature) -> |
| 14 | # manifest + image written beside SPOOL/next.job and renamed into place. |
| 15 | # Final line: "NETBOOT_PUSH: QUEUED <job> sha256=<image sha256>" (exit 0) or an error (exit 1). |
| 16 | set -euo pipefail |
| 17 | repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 18 | img="${1:?usage: ck_imac_netboot_push.sh IMAGE.EFI [KEY] [SPOOL]}" |
| 19 | key="${2:-${HOME}/.config/aienos/imac-netboot.key}" |
| 20 | spool="${3:-${HOME}/.local/state/aienos/imac-netboot}" |
| 21 | out="${NETBOOT_TOOL_OUT:-${repo_root}/target/native-kernel-imac-netboot}" |
| 22 | make -s -C "${repo_root}/native/kernel" OUT="${out}" slot-tool imac-netboot-tool >/dev/null |
| 23 | st="${out}/host/ck_slot_tool" |
| 24 | nb="${out}/host/ck_imac_netboot" |
| 25 | [[ -r "${img}" ]] || { echo "NETBOOT_PUSH: no image ${img}"; exit 1; } |
| 26 | [[ "$(head -c 2 "${img}")" == "MZ" ]] || { echo "NETBOOT_PUSH: ${img} is not a PE image"; exit 1; } |
| 27 | mkdir -p "${spool}" |
| 28 | work="$(mktemp -d "${spool}/.push.XXXXXX")" |
| 29 | trap 'rm -rf "${work}"' EXIT |
| 30 | commit="$(git -C "${repo_root}" rev-parse HEAD)" |
| 31 | pk="$("${nb}" pubkey "${key}")" |
| 32 | "${st}" make-manifest --image "${img}" --generation "$(date +%s)" --commit "${commit}" \ |
| 33 | --provenance "imac-netboot lab $(basename "${img}")" --out "${work}/m0" >/dev/null |
| 34 | "${st}" tbs "${work}/m0" --pubkey "${pk}" --out "${work}/tbs" >/dev/null |
| 35 | "${nb}" sign "${key}" "${work}/tbs" "${work}/sig" >/dev/null |
| 36 | "${st}" attach-sig "${work}/m0" --sig "${work}/sig" --pubkey "${pk}" --out "${work}/m1" >/dev/null |
| 37 | [[ "$(stat -c %s "${work}/m1")" == 4096 ]] || { echo "NETBOOT_PUSH: manifest is not 4096 bytes"; exit 1; } |
| 38 | cat "${work}/m1" "${img}" >"${work}/job" |
| 39 | mv "${work}/job" "${spool}/next.job" |
| 40 | echo "NETBOOT_PUSH: QUEUED ${spool}/next.job sha256=$(sha256sum "${img}" | cut -d' ' -f1)" |