fix: rewrite clawd.service on upgrade; bump to 1.2.6

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
stswangzhiping
2026-05-04 18:46:37 +08:00
parent 7761b438d3
commit 45e1370ca5
2 changed files with 49 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "clawd", "name": "clawd",
"version": "1.2.5", "version": "1.2.6",
"description": "Claw Box daemon - connects local Linux box to claw.cutos.ai via WebSocket", "description": "Claw Box daemon - connects local Linux box to claw.cutos.ai via WebSocket",
"main": "lib/client.js", "main": "lib/client.js",
"bin": { "bin": {

View File

@@ -63,20 +63,55 @@ if [ "$NO_RESTART" = true ]; then
exit 0 exit 0
fi fi
# Patch service file if ReadWritePaths is missing /etc/hosts or /etc/hostname NODE_BIN=$(command -v node)
INSTALL_DIR="/opt/clawd"
CONFIG_DIR="/etc/clawd"
ENV_FILE="$CONFIG_DIR/env"
SERVICE_FILE="/etc/systemd/system/$SERVICE" SERVICE_FILE="/etc/systemd/system/$SERVICE"
if [ -f "$SERVICE_FILE" ]; then
if ! grep -q "/etc/hosts" "$SERVICE_FILE" || ! grep -q "/etc/hostname" "$SERVICE_FILE"; then echo "==> Writing service file: $SERVICE_FILE"
echo "==> Patching $SERVICE_FILE: adding /etc/hosts /etc/hostname to ReadWritePaths ..." cat > "$SERVICE_FILE" <<EOF
sed -i 's|ReadWritePaths=\(.*\)/tmp\(.*\)|ReadWritePaths=\1/tmp\2 /etc/hosts /etc/hostname|' "$SERVICE_FILE" [Unit]
# If the pattern didn't match (different format), append directly Description=Claw Box Daemon
if ! grep -q "/etc/hosts" "$SERVICE_FILE"; then Documentation=https://git.cutos.ai/claw-daemon/clawd
sed -i 's|ReadWritePaths=.*|& /etc/hosts /etc/hostname|' "$SERVICE_FILE" After=NetworkManager.service
fi Wants=NetworkManager.service
systemctl daemon-reload
echo "==> daemon-reload done" [Service]
fi Type=simple
fi NotifyAccess=all
EnvironmentFile=$ENV_FILE
ExecStart=$NODE_BIN $INSTALL_DIR/bin/clawd.js
WorkingDirectory=$INSTALL_DIR
Restart=always
RestartSec=5
StartLimitInterval=300
StartLimitBurst=10
TimeoutStopSec=10
KillMode=mixed
KillSignal=SIGTERM
MemoryMax=256M
CPUQuota=50%
TasksMax=64
ProtectSystem=full
ReadWritePaths=$CONFIG_DIR /tmp /etc/hosts /etc/hostname
StandardOutput=journal
StandardError=journal
SyslogIdentifier=clawd
WatchdogSec=60
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
echo "==> daemon-reload done"
echo "==> Restarting service: $SERVICE" echo "==> Restarting service: $SERVICE"
systemctl restart "$SERVICE" systemctl restart "$SERVICE"