Keep pi-web service static

This commit is contained in:
yankun
2026-08-02 18:20:11 +08:00
parent f283674da3
commit 118053189c
-24
View File
@@ -127,7 +127,6 @@ resolve_bin() {
write_pi_web_service() { write_pi_web_service() {
local pi_web_bin="$1" local pi_web_bin="$1"
local service_file="/etc/systemd/system/pi-web.service" local service_file="/etc/systemd/system/pi-web.service"
local allowed_hosts="$PI_WEB_ALLOWED_HOSTS_VALUE"
info "Writing pi-web systemd service ..." info "Writing pi-web systemd service ..."
run_root tee "$service_file" >/dev/null <<EOF run_root tee "$service_file" >/dev/null <<EOF
@@ -140,7 +139,6 @@ Wants=network-online.target
Type=simple Type=simple
User=$TARGET_USER User=$TARGET_USER
Environment=HOME=$TARGET_HOME Environment=HOME=$TARGET_HOME
Environment=PI_WEB_ALLOWED_HOSTS=$allowed_hosts
WorkingDirectory=$PI_HOME WorkingDirectory=$PI_HOME
ExecStart=$pi_web_bin --no-open ExecStart=$pi_web_bin --no-open
Restart=always Restart=always
@@ -155,21 +153,6 @@ EOF
run_root systemctl restart pi-web.service run_root systemctl restart pi-web.service
} }
detect_pi_web_allowed_hosts() {
local config_file="/etc/clawd/config.json"
local claw_id=""
if run_root test -f "$config_file"; then
claw_id="$(run_root node -e "const fs=require('fs'); const p='$config_file'; try { const v=JSON.parse(fs.readFileSync(p,'utf8')).claw_id; if (v !== null && v !== undefined && String(v).trim()) process.stdout.write(String(v).trim()); } catch {}" 2>/dev/null || true)"
fi
if [ -n "$claw_id" ]; then
printf '%s.claw.cutos.ai' "$claw_id"
else
printf ''
fi
}
configure_clawd_agent_type() { configure_clawd_agent_type() {
local config_dir="/etc/clawd" local config_dir="/etc/clawd"
local env_file="$config_dir/env" local env_file="$config_dir/env"
@@ -214,15 +197,9 @@ TARGET_USER="$(detect_user)"
TARGET_HOME="$(detect_home "$TARGET_USER")" TARGET_HOME="$(detect_home "$TARGET_USER")"
TARGET_GROUP="$(id -gn "$TARGET_USER" 2>/dev/null || printf '%s' "$TARGET_USER")" TARGET_GROUP="$(id -gn "$TARGET_USER" 2>/dev/null || printf '%s' "$TARGET_USER")"
PI_HOME="$TARGET_HOME/.pi" PI_HOME="$TARGET_HOME/.pi"
PI_WEB_ALLOWED_HOSTS_VALUE="$(detect_pi_web_allowed_hosts)"
info "Installing for user: $TARGET_USER" info "Installing for user: $TARGET_USER"
info "Pi working directory: $PI_HOME" info "Pi working directory: $PI_HOME"
if [ -n "$PI_WEB_ALLOWED_HOSTS_VALUE" ]; then
info "Pi Web allowed hosts: $PI_WEB_ALLOWED_HOSTS_VALUE"
else
warn "claw_id not found in /etc/clawd/config.json; Pi Web external host is not configured yet."
fi
configure_clawd_agent_type configure_clawd_agent_type
@@ -265,7 +242,6 @@ CutOS Agent install complete.
Pi home: $PI_HOME Pi home: $PI_HOME
Service: pi-web.service Service: pi-web.service
Pi Web allowed hosts: ${PI_WEB_ALLOWED_HOSTS_VALUE:-not configured}
clawd env: /etc/clawd/env clawd env: /etc/clawd/env
Logs: journalctl -u pi-web -f Logs: journalctl -u pi-web -f
Console: http://127.0.0.1:30141/ Console: http://127.0.0.1:30141/