From 00db9d3c3f43ccb6753ee3fc9ebdc3c8cbcac8f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B0=E6=9C=94?= <565183519@qq.com> Date: Sat, 1 Aug 2026 18:18:41 +0800 Subject: [PATCH] feat: add verified BS-SH-005 runtime installer --- .../scripts/install-bs-sh-005.sh | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 engineering/persona-history-runtime/scripts/install-bs-sh-005.sh diff --git a/engineering/persona-history-runtime/scripts/install-bs-sh-005.sh b/engineering/persona-history-runtime/scripts/install-bs-sh-005.sh new file mode 100644 index 0000000..16fc6ae --- /dev/null +++ b/engineering/persona-history-runtime/scripts/install-bs-sh-005.sh @@ -0,0 +1,96 @@ +#!/bin/sh +set -eu + +if [ "$(id -u)" -ne 0 ]; then + echo "installer must run as root" >&2 + exit 77 +fi + +source_root=${1:?source root required} +version=${2:?version required} +archive_sha256=${3:?archive SHA-256 required} + +runtime_root=/opt/guanghu/persona-history +target_root="${runtime_root}/${version}" +current_link="${runtime_root}/current" +config_target=/etc/guanghu/persona-history.json +state_root=/var/lib/guanghu/persona-history +private_source_root=/guanghu/gestation/private/history-sources +receipt_root=/guanghu/gestation/receipts/persona-history +unit_target=/etc/systemd/system/guanghu-persona-history-recovery.service + +previous_target=NONE +if [ -L "${current_link}" ]; then + previous_target=$(readlink "${current_link}") +fi + +if ! id guanghu-history >/dev/null 2>&1; then + useradd \ + --system \ + --home-dir "${state_root}" \ + --shell /usr/sbin/nologin \ + --user-group \ + guanghu-history +fi + +install -d -o root -g root -m 0755 "${target_root}" +install -d -o root -g root -m 0755 "${target_root}/runtime" +install -m 0755 \ + "${source_root}/runtime/guanghu_history_runtime.py" \ + "${target_root}/runtime/guanghu_history_runtime.py" +install -m 0644 \ + "${source_root}/config/BS-SH-005.json" \ + "${target_root}/BS-SH-005.json" +install -m 0644 \ + "${source_root}/world/PERSONA-HISTORY-REALITY-BOUNDARY.hldp" \ + "${target_root}/PERSONA-HISTORY-REALITY-BOUNDARY.hldp" + +install -d -o root -g guanghu-history -m 0750 /etc/guanghu +install -m 0640 -o root -g guanghu-history \ + "${source_root}/config/BS-SH-005.json" \ + "${config_target}" +install -d -o guanghu-history -g guanghu-history -m 0750 "${state_root}" +install -d -o guanghu-history -g guanghu-history -m 0750 "${state_root}/public" +install -d -o root -g guanghu-history -m 0750 "${private_source_root}" +install -d -o root -g root -m 0755 "${receipt_root}" + +ln -sfn "${target_root}/runtime" "${current_link}" +install -m 0644 \ + "${source_root}/packaging/guanghu-persona-history-recovery.service" \ + "${unit_target}" + +"${current_link}/guanghu_history_runtime.py" validate --config "${config_target}" +systemctl daemon-reload +systemctl enable guanghu-persona-history-recovery.service +systemctl restart guanghu-persona-history-recovery.service + +sleep 2 +systemctl is-active --quiet guanghu-persona-history-recovery.service +health=$(curl -fsS http://127.0.0.1:8089/healthz) +echo "${health}" | grep -q '"status": "ok"' + +observed_at=$(date -Is) +receipt="${receipt_root}/BS-SH-005-PERSONA-HISTORY-RUNTIME-INSTALL-${version}.hldp" +pending="${receipt}.pending" +cat >"${pending}" <