fix: rewrite clawd.service on upgrade; bump to 1.2.6
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clawd",
|
||||
"version": "1.2.5",
|
||||
"version": "1.2.6",
|
||||
"description": "Claw Box daemon - connects local Linux box to claw.cutos.ai via WebSocket",
|
||||
"main": "lib/client.js",
|
||||
"bin": {
|
||||
|
||||
@@ -63,20 +63,55 @@ if [ "$NO_RESTART" = true ]; then
|
||||
exit 0
|
||||
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"
|
||||
if [ -f "$SERVICE_FILE" ]; then
|
||||
if ! grep -q "/etc/hosts" "$SERVICE_FILE" || ! grep -q "/etc/hostname" "$SERVICE_FILE"; then
|
||||
echo "==> Patching $SERVICE_FILE: adding /etc/hosts /etc/hostname to ReadWritePaths ..."
|
||||
sed -i 's|ReadWritePaths=\(.*\)/tmp\(.*\)|ReadWritePaths=\1/tmp\2 /etc/hosts /etc/hostname|' "$SERVICE_FILE"
|
||||
# If the pattern didn't match (different format), append directly
|
||||
if ! grep -q "/etc/hosts" "$SERVICE_FILE"; then
|
||||
sed -i 's|ReadWritePaths=.*|& /etc/hosts /etc/hostname|' "$SERVICE_FILE"
|
||||
fi
|
||||
|
||||
echo "==> Writing service file: $SERVICE_FILE"
|
||||
cat > "$SERVICE_FILE" <<EOF
|
||||
[Unit]
|
||||
Description=Claw Box Daemon
|
||||
Documentation=https://git.cutos.ai/claw-daemon/clawd
|
||||
After=NetworkManager.service
|
||||
Wants=NetworkManager.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
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"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "==> Restarting service: $SERVICE"
|
||||
systemctl restart "$SERVICE"
|
||||
|
||||
Reference in New Issue
Block a user