fix(install): install gateway daemon service for fresh installs

- Add install_gateway_daemon_if_needed() function
- Call daemon install and daemon start for new installs
- Skip for upgrades (existing behavior)
- Fixes #48272 where gateway was not installed

Root cause:
The install script only refreshed the gateway service if it was already
loaded, but never installed it for fresh installs.

Fix:
1. Check if gateway daemon is already installed
2. If not, run 'openclaw daemon install'
3. Then run 'openclaw daemon start'
4. Probe the daemon to verify it's running
This commit is contained in:
w-sss 2026-03-17 00:32:15 +08:00
parent e554eee541
commit 0387f0f62c

View File

@ -2243,6 +2243,45 @@ refresh_gateway_service_if_loaded() {
run_quiet_step "Probing gateway service" "$claw" gateway status --deep || true
}
install_gateway_daemon_if_needed() {
if [[ "${SKIP_GATEWAY_DAEMON:-0}" == "1" ]]; then
ui_info "Skipping gateway daemon installation (SKIP_GATEWAY_DAEMON=1)"
return 0
fi
local claw="${OPENCLAW_BIN:-}"
if [[ -z "$claw" ]]; then
claw="$(resolve_openclaw_bin || true)"
fi
if [[ -z "$claw" ]]; then
ui_info "Skipping gateway daemon install (openclaw not on PATH yet)"
return 0
fi
if is_gateway_daemon_loaded "$claw"; then
ui_info "Gateway daemon already installed; skipping install"
return 0
fi
ui_info "Installing gateway daemon service"
if run_quiet_step "Installing gateway daemon" "$claw" daemon install; then
ui_success "Gateway daemon service installed"
else
ui_warn "Gateway daemon install failed; user can run 'openclaw daemon install' manually"
return 0
fi
if run_quiet_step "Starting gateway daemon" "$claw" daemon start; then
ui_success "Gateway daemon service started"
else
ui_warn "Gateway daemon start failed; user can run 'openclaw daemon start' manually"
return 0
fi
sleep 2
run_quiet_step "Probing gateway daemon" "$claw" daemon status --deep || true
}
verify_installation() {
if [[ "${VERIFY_INSTALL}" != "1" ]]; then
return 0
@ -2400,6 +2439,11 @@ main() {
fi
fi
# Install gateway daemon for fresh installs (not upgrades)
if [[ "$is_upgrade" != "true" ]]; then
install_gateway_daemon_if_needed
fi
refresh_gateway_service_if_loaded
# Step 6: Run doctor for migrations on upgrades and git installs