From 2460a72b34aeff6c194e390d6e546220bc0bf86d Mon Sep 17 00:00:00 2001 From: yankun Date: Sun, 2 Aug 2026 17:02:24 +0800 Subject: [PATCH] Configure clawd agent type during install --- install.sh | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 73a90b4..4ffdeb4 100755 --- a/install.sh +++ b/install.sh @@ -139,7 +139,6 @@ Wants=network-online.target Type=simple User=$TARGET_USER Environment=HOME=$TARGET_HOME -Environment=AGENT_TYPE=cutos-agent WorkingDirectory=$PI_HOME ExecStart=$pi_web_bin --no-open Restart=always @@ -154,6 +153,36 @@ EOF run_root systemctl restart pi-web.service } +configure_clawd_agent_type() { + local config_dir="/etc/clawd" + local env_file="$config_dir/env" + + info "Configuring clawd AGENT_TYPE=cutos-agent ..." + run_root mkdir -p "$config_dir" + + if run_root test -f "$env_file"; then + if run_root grep -q '^[[:space:]]*AGENT_TYPE=' "$env_file"; then + run_root sed -i 's/^[[:space:]]*AGENT_TYPE=.*/AGENT_TYPE=cutos-agent/' "$env_file" + elif run_root grep -q '^[[:space:]]*# AGENT_TYPE=' "$env_file"; then + run_root sed -i 's/^[[:space:]]*# AGENT_TYPE=.*/AGENT_TYPE=cutos-agent/' "$env_file" + else + printf '\nAGENT_TYPE=cutos-agent\n' | run_root tee -a "$env_file" >/dev/null + fi + else + run_root tee "$env_file" >/dev/null </dev/null 2>&1 && run_root systemctl cat clawd.service >/dev/null 2>&1; then + info "Restarting clawd to apply AGENT_TYPE ..." + if ! run_root systemctl restart clawd.service; then + warn "clawd restart failed. Check logs with: journalctl -u clawd -n 50 --no-pager" + fi + fi +} + require_command node require_command npm @@ -172,6 +201,8 @@ PI_HOME="$TARGET_HOME/.pi" info "Installing for user: $TARGET_USER" info "Pi working directory: $PI_HOME" +configure_clawd_agent_type + run_root mkdir -p "$PI_HOME" if [ "$TARGET_USER" != "root" ]; then run_root chown "$TARGET_USER:$TARGET_GROUP" "$PI_HOME" @@ -211,6 +242,7 @@ CutOS Agent install complete. Pi home: $PI_HOME Service: pi-web.service + clawd env: /etc/clawd/env Logs: journalctl -u pi-web -f Console: http://127.0.0.1:30141/