fix(codex): make gateway activation transactional
This commit is contained in:
@@ -122,9 +122,6 @@ if [[ -L "$INSTALL_ROOT/current" ]]; then
|
||||
PREVIOUS_TARGET="$(readlink -f "$INSTALL_ROOT/current")"
|
||||
fi
|
||||
|
||||
ln -s "$RELEASE_DIR" "$INSTALL_ROOT/.current-new-$$"
|
||||
mv -Tf "$INSTALL_ROOT/.current-new-$$" "$INSTALL_ROOT/current"
|
||||
|
||||
install -m 0644 "$SOURCE_ROOT/systemd/aios-orchestrator-gateway.service" \
|
||||
"$UNIT_ROOT/aios-orchestrator-gateway.service"
|
||||
install -m 0644 "$SOURCE_ROOT/systemd/aios-orchestrator-gateway-poll.service" \
|
||||
@@ -158,9 +155,24 @@ chmod 0640 "$CONFIG_ROOT/callback.token"
|
||||
|
||||
# Historical installers appended one LF. Remove only that exact legacy byte in
|
||||
# place; reject every other newline form without ever copying or printing data.
|
||||
python3 - "$CONFIG_ROOT/inbound.token" "$CONFIG_ROOT/callback.token" <<'PY'
|
||||
import os, stat, sys
|
||||
for name in sys.argv[1:]:
|
||||
python3 - "$CONFIG_ROOT/config.json" "$CONFIG_ROOT/inbound.token" "$CONFIG_ROOT/callback.token" <<'PY'
|
||||
import json, os, pathlib, stat, sys
|
||||
config_path = pathlib.Path(sys.argv[1])
|
||||
names = list(sys.argv[2:])
|
||||
if config_path.is_file() and not config_path.is_symlink():
|
||||
config = json.loads(config_path.read_text())
|
||||
candidates = [
|
||||
config.get("inbound_token_file"),
|
||||
config.get("callback_token_file"),
|
||||
(config.get("workspace_agent") or {}).get("access_token_file"),
|
||||
(config.get("responses_fallback") or {}).get("api_key_file"),
|
||||
(config.get("openclaw_sync") or {}).get("bearer_token_file"),
|
||||
]
|
||||
names.extend(name for name in candidates if isinstance(name, str) and name)
|
||||
for name in dict.fromkeys(names):
|
||||
path = pathlib.Path(name)
|
||||
if not path.is_absolute() or path.is_symlink() or path.resolve() != path:
|
||||
raise SystemExit("invalid token path")
|
||||
fd = os.open(name, os.O_RDWR | getattr(os, "O_NOFOLLOW", 0))
|
||||
try:
|
||||
info = os.fstat(fd)
|
||||
@@ -191,7 +203,7 @@ chmod 0640 "$CONFIG_ROOT/config.json"
|
||||
python3 -m json.tool "$CONFIG_ROOT/config.json" >/dev/null
|
||||
AIOS_ORCHESTRATOR_CONFIG_OWNER_UID=0 \
|
||||
AIOS_ORCHESTRATOR_SECRET_OWNER_UID=0 \
|
||||
PYTHONPATH="$INSTALL_ROOT/current" \
|
||||
PYTHONPATH="$RELEASE_DIR" \
|
||||
python3 - "$CONFIG_ROOT/config.json" <<'PY'
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -208,6 +220,11 @@ if cfg.openclaw_sync_endpoint:
|
||||
print("CONFIG_VALIDATE=PASS")
|
||||
PY
|
||||
|
||||
# Commit the release pointer only after every candidate/config/secret check has
|
||||
# succeeded. A failed validation therefore leaves the running release intact.
|
||||
ln -s "$RELEASE_DIR" "$INSTALL_ROOT/.current-new-$$"
|
||||
mv -Tf "$INSTALL_ROOT/.current-new-$$" "$INSTALL_ROOT/current"
|
||||
|
||||
python3 - "$STATE_ROOT/install-receipt.json" "$SOURCE_DIGEST" "$RELEASE_DIR" "$PREVIOUS_TARGET" <<'PY'
|
||||
import json, os, sys, tempfile
|
||||
from pathlib import Path
|
||||
|
||||
Reference in New Issue
Block a user