Configure clawd agent type during install
This commit is contained in:
+33
-1
@@ -139,7 +139,6 @@ Wants=network-online.target
|
|||||||
Type=simple
|
Type=simple
|
||||||
User=$TARGET_USER
|
User=$TARGET_USER
|
||||||
Environment=HOME=$TARGET_HOME
|
Environment=HOME=$TARGET_HOME
|
||||||
Environment=AGENT_TYPE=cutos-agent
|
|
||||||
WorkingDirectory=$PI_HOME
|
WorkingDirectory=$PI_HOME
|
||||||
ExecStart=$pi_web_bin --no-open
|
ExecStart=$pi_web_bin --no-open
|
||||||
Restart=always
|
Restart=always
|
||||||
@@ -154,6 +153,36 @@ EOF
|
|||||||
run_root systemctl restart pi-web.service
|
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 <<EOF
|
||||||
|
# clawd environment (loaded by systemd EnvironmentFile)
|
||||||
|
AGENT_TYPE=cutos-agent
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v systemctl >/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 node
|
||||||
require_command npm
|
require_command npm
|
||||||
|
|
||||||
@@ -172,6 +201,8 @@ PI_HOME="$TARGET_HOME/.pi"
|
|||||||
info "Installing for user: $TARGET_USER"
|
info "Installing for user: $TARGET_USER"
|
||||||
info "Pi working directory: $PI_HOME"
|
info "Pi working directory: $PI_HOME"
|
||||||
|
|
||||||
|
configure_clawd_agent_type
|
||||||
|
|
||||||
run_root mkdir -p "$PI_HOME"
|
run_root mkdir -p "$PI_HOME"
|
||||||
if [ "$TARGET_USER" != "root" ]; then
|
if [ "$TARGET_USER" != "root" ]; then
|
||||||
run_root chown "$TARGET_USER:$TARGET_GROUP" "$PI_HOME"
|
run_root chown "$TARGET_USER:$TARGET_GROUP" "$PI_HOME"
|
||||||
@@ -211,6 +242,7 @@ CutOS Agent install complete.
|
|||||||
|
|
||||||
Pi home: $PI_HOME
|
Pi home: $PI_HOME
|
||||||
Service: pi-web.service
|
Service: pi-web.service
|
||||||
|
clawd env: /etc/clawd/env
|
||||||
Logs: journalctl -u pi-web -f
|
Logs: journalctl -u pi-web -f
|
||||||
Console: http://127.0.0.1:30141/
|
Console: http://127.0.0.1:30141/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user