fix: resolve hardcoded /root paths in CLI and utility scripts

All scripts now use os.path.dirname(os.path.abspath(__file__)) to
dynamically resolve paths relative to their location, consistent
with backend/app.py. Also fixes healthcheck.sh to use --fail and
--max-time for curl, and corrects port references to 19000.

Affected files:
- set_state.py
- healthcheck.sh
- office-agent-push.py
- convert_to_webp.py
- repack_star_working.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kyle ChenandClaude Opus 4.6 committed 2026-03-02 12:29:10 +08:00
1 parent 04733eaed3
commit 084bf4dfaa
5 files changed
+13 -10

No files matched your search

+2 -1
View File
@@ -9,7 +9,8 @@ import os
from PIL import Image
# 路径
FRONTEND_DIR = "/root/.openclaw/workspace/star-office-ui/frontend"
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
FRONTEND_DIR = os.path.join(ROOT_DIR, "frontend")
STATIC_DIR = os.path.join(FRONTEND_DIR, "")
# 文件分类配置
+5 -3
View File
@@ -2,14 +2,16 @@
# Star Office UI Health Check
# Checks if backend is responding, restarts if not
BACKEND_URL="http://127.0.0.1:18791/health"
LOG_FILE="/root/.openclaw/workspace/star-office-ui/healthcheck.log"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
OFFICE_PORT="${OFFICE_PORT:-19000}"
BACKEND_URL="http://127.0.0.1:${OFFICE_PORT}/health"
LOG_FILE="${SCRIPT_DIR}/healthcheck.log"
# Log timestamp
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Health check starting..." >> "$LOG_FILE"
# Check backend
if curl -sS "$BACKEND_URL" > /dev/null 2>&1; then
if curl -fsS --max-time 5 "$BACKEND_URL" > /dev/null 2>&1; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Backend is healthy" >> "$LOG_FILE"
else
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Backend is NOT healthy - restarting..." >> "$LOG_FILE"
+3 -4
View File
@@ -31,16 +31,15 @@ STATE_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "office-ag
# 优先读取本机 OpenClaw 工作区的状态文件(更贴合 AGENTS.md 的工作流)
# 支持自动发现,减少对方手动配置成本。
_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
DEFAULT_STATE_CANDIDATES = [
"/root/.openclaw/workspace/star-office-ui/state.json",
"/root/.openclaw/workspace/state.json",
os.path.join(_SCRIPT_DIR, "state.json"),
os.path.join(os.getcwd(), "state.json"),
os.path.join(os.path.dirname(os.path.abspath(__file__)), "state.json"),
]
# 如果对方本地 /status 需要鉴权,可在这里填写 token(或通过环境变量 OFFICE_LOCAL_STATUS_TOKEN)
LOCAL_STATUS_TOKEN = os.environ.get("OFFICE_LOCAL_STATUS_TOKEN", "")
LOCAL_STATUS_URL = os.environ.get("OFFICE_LOCAL_STATUS_URL", "http://127.0.0.1:18791/status")
LOCAL_STATUS_URL = os.environ.get("OFFICE_LOCAL_STATUS_URL", "http://127.0.0.1:19000/status")
# 可选:直接指定本地状态文件路径(最简单方案:绕过 /status 鉴权)
LOCAL_STATE_FILE = os.environ.get("OFFICE_LOCAL_STATE_FILE", "")
VERBOSE = os.environ.get("OFFICE_VERBOSE", "0") in {"1", "true", "TRUE", "yes", "YES"}
+1 -1
View File
@@ -23,7 +23,7 @@ import math
import os
from PIL import Image
ROOT = "/root/.openclaw/workspace/star-office-ui"
ROOT = os.path.dirname(os.path.abspath(__file__))
IN_PATH = os.path.join(ROOT, "frontend", "star-working-spritesheet.png")
OUT_PATH = os.path.join(ROOT, "frontend", "star-working-spritesheet-grid.png")
+2 -1
View File
@@ -6,7 +6,8 @@ import os
import sys
from datetime import datetime
STATE_FILE = "/root/.openclaw/workspace/star-office-ui/state.json"
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
STATE_FILE = os.path.join(ROOT_DIR, "state.json")
VALID_STATES = [
"idle",