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": {