From 9e67969fd12288bcf7b5c72969154d99dcc192f4 Mon Sep 17 00:00:00 2001 From: stswangzhiping <59632378+stswangzhiping@users.noreply.github.com> Date: Mon, 4 May 2026 17:45:35 +0800 Subject: [PATCH] fix: hostname - remove sudo (clawd runs as root), use semicolon to run all 3 commands independently; bump v1.2.4 Co-authored-by: Cursor --- lib/client.js | 14 ++++++++------ package.json | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/client.js b/lib/client.js index e220a04..30c32fa 100644 --- a/lib/client.js +++ b/lib/client.js @@ -508,16 +508,18 @@ class ClawClient { _setHostname(clawId) { const hostname = `claw-${clawId}`; + // clawd runs as root (no User= in service), no sudo needed. + // Use ';' not '&&' so each command runs independently even if one fails. const cmd = [ - `sudo hostname ${hostname}`, - `echo "${hostname}" | sudo tee /etc/hostname > /dev/null`, - `sudo sed -i 's/^127\\.0\\.1\\.1.*/127.0.1.1 ${hostname}/' /etc/hosts`, - ].join(' && '); + `hostname ${hostname}`, + `echo "${hostname}" > /etc/hostname`, + `sed -i 's/^127\\.0\\.1\\.1.*/127.0.1.1 ${hostname}/' /etc/hosts`, + ].join('; '); exec(cmd, { shell: true }, (err) => { if (err) { - log.warn('clawd', `设置 hostname 失败: ${err.message}`); + log.warn('clawd', `hostname set failed: ${err.message}`); } else { - log.info('clawd', `hostname → ${hostname}`); + log.info('clawd', `hostname -> ${hostname}`); } }); } diff --git a/package.json b/package.json index 8a2b1fe..5529420 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clawd", - "version": "1.2.2", + "version": "1.2.4", "description": "Claw Box daemon - connects local Linux box to claw.cutos.ai via WebSocket", "main": "lib/client.js", "bin": {