feat: run at boot (systemd/launchd) and auth token re-sync docs
- Add systemd unit examples and README for local install (Linux) - Extend deployment README with Run at boot (local install) and merge upstream - Add Re-syncing auth tokens subsection to gateway provisioning troubleshooting - install.sh: add --install-service to install systemd user units (Linux) - DOCUMENTATION.md: session notes Made-with: Cursor
This commit is contained in:
52
install.sh
52
install.sh
@@ -30,6 +30,7 @@ FORCE_LOCAL_AUTH_TOKEN=""
|
||||
FORCE_DB_MODE=""
|
||||
FORCE_DATABASE_URL=""
|
||||
FORCE_START_SERVICES=""
|
||||
FORCE_INSTALL_SERVICE=""
|
||||
|
||||
if [[ -t 0 ]]; then
|
||||
INTERACTIVE=1
|
||||
@@ -131,6 +132,7 @@ Options:
|
||||
--db-mode <docker|external> Local mode only
|
||||
--database-url <url> Required when --db-mode external
|
||||
--start-services <yes|no> Local mode only
|
||||
--install-service Local mode only: install systemd user units for run at boot (Linux)
|
||||
-h, --help
|
||||
|
||||
If an option is omitted, the script prompts in interactive mode and uses defaults in non-interactive mode.
|
||||
@@ -220,6 +222,10 @@ parse_args() {
|
||||
FORCE_START_SERVICES="$2"
|
||||
shift 2
|
||||
;;
|
||||
--install-service)
|
||||
FORCE_INSTALL_SERVICE="yes"
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
@@ -733,6 +739,45 @@ start_local_services() {
|
||||
)
|
||||
}
|
||||
|
||||
install_systemd_services() {
|
||||
local backend_port="$1"
|
||||
local frontend_port="$2"
|
||||
local systemd_user_dir
|
||||
systemd_user_dir="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"
|
||||
local units_dir="$REPO_ROOT/docs/deployment/systemd"
|
||||
|
||||
if [[ "$PLATFORM" != "linux" ]]; then
|
||||
info "Skipping systemd install (not Linux). For macOS run-at-boot see docs/deployment/README.md (launchd)."
|
||||
return 0
|
||||
fi
|
||||
if [[ ! -d "$units_dir" ]]; then
|
||||
warn "Systemd units dir not found: $units_dir"
|
||||
return 1
|
||||
fi
|
||||
for name in openclaw-mission-control-backend openclaw-mission-control-frontend openclaw-mission-control-rq-worker; do
|
||||
if [[ ! -f "$units_dir/$name.service" ]]; then
|
||||
warn "Unit file not found: $units_dir/$name.service"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir -p "$systemd_user_dir"
|
||||
for name in openclaw-mission-control-backend openclaw-mission-control-frontend openclaw-mission-control-rq-worker; do
|
||||
sed -e "s|REPO_ROOT|$REPO_ROOT|g" \
|
||||
-e "s|BACKEND_PORT|$backend_port|g" \
|
||||
-e "s|FRONTEND_PORT|$frontend_port|g" \
|
||||
"$units_dir/$name.service" > "$systemd_user_dir/$name.service"
|
||||
info "Installed $systemd_user_dir/$name.service"
|
||||
done
|
||||
if command_exists systemctl; then
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable openclaw-mission-control-backend openclaw-mission-control-frontend openclaw-mission-control-rq-worker
|
||||
info "Systemd user units enabled. Start with: systemctl --user start openclaw-mission-control-backend openclaw-mission-control-frontend openclaw-mission-control-rq-worker"
|
||||
else
|
||||
warn "systemctl not found; units were copied but not enabled."
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_repo_layout() {
|
||||
[[ -f "$REPO_ROOT/Makefile" ]] || die "Missing Makefile in expected repository root: $REPO_ROOT"
|
||||
[[ -f "$REPO_ROOT/compose.yml" ]] || die "Missing compose.yml in expected repository root: $REPO_ROOT"
|
||||
@@ -954,6 +999,10 @@ SUMMARY
|
||||
wait_for_http "http://127.0.0.1:$frontend_port" "Frontend" 120 || true
|
||||
fi
|
||||
|
||||
if [[ -n "$FORCE_INSTALL_SERVICE" ]]; then
|
||||
install_systemd_services "$backend_port" "$frontend_port" || true
|
||||
fi
|
||||
|
||||
cat <<SUMMARY
|
||||
|
||||
Bootstrap complete (Local mode).
|
||||
@@ -973,6 +1022,9 @@ If services were started by this script, logs are under:
|
||||
Stop local background services:
|
||||
kill "\$(cat $LOG_DIR/backend.pid)" "\$(cat $LOG_DIR/frontend.pid)"
|
||||
SUMMARY
|
||||
if [[ -n "$FORCE_INSTALL_SERVICE" && "$PLATFORM" == "linux" ]]; then
|
||||
info "Run at boot: systemd user units were installed and enabled. Start with: systemctl --user start openclaw-mission-control-backend openclaw-mission-control-frontend openclaw-mission-control-rq-worker"
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user