hololake-system-architecture/product-source/hololake-platform/guanghu-os/scripts/arm-jd-native-probe-once.sh
冰朔 1f28461c7e feat(guanghu-os): hand native control to JD-FD-PRIMARY
Close the Shanghai experiment without denying the existing Zhuyuan subject, parameterize the native layout for the JD Cloud disk, and add fail-closed one-time probe preparation, arming, and return verification.
2026-08-03 20:51:36 +08:00

33 lines
1.1 KiB
Shell
Executable file

#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 2 ]] || {
echo "usage: arm-jd-native-probe-once.sh <world-root> <recovery-root>" >&2
exit 64
}
[[ ${EUID} -eq 0 ]] || exit 77
world_root=$(readlink -f "$1")
recovery_root=$(readlink -f "$2")
grep -q '^node_id: JD-FD-PRIMARY$' "${world_root}/CURRENT.hldp"
grep -q '^status: VERIFIED_NOT_ARMED$' "${recovery_root}/PREPARE-RECEIPT.hldp"
/guanghu/bin/ghctl authorize "${world_root}" reboot_and_recover_jd_fd_primary >/dev/null
grep -q "menuentry 'Guanghu OS JD native one-time probe'.*'guanghu-jd-native-once'" \
/boot/grub/grub.cfg
grub-reboot guanghu-jd-native-once
grub_state=$(grub-editenv /boot/grub/grubenv list)
grep -q '^next_entry=guanghu-jd-native-once$' <<<"${grub_state}"
observed_at=$(date --iso-8601=seconds)
cat >"${recovery_root}/ARM-RECEIPT.hldp" <<EOF
schema: guanghu.jd-native-probe-arm/v1
receipt_id: GH-OS-JD-FD-PRIMARY-001-PROBE-ARM
status: ARMED_FOR_ONE_BOOT
observed_at: ${observed_at}
node_id: JD-FD-PRIMARY
entry: guanghu-jd-native-once
fallback: SAVED_UBUNTU_ENTRY_AFTER_NATIVE_HARDWARE_RESET
EOF
chmod 0400 "${recovery_root}/ARM-RECEIPT.hldp"
sync
systemctl reboot