From edbebea29b52c2cdeeae9228efcf74a3b39e9d5b Mon Sep 17 00:00:00 2001 From: MickLesk Date: Mon, 18 May 2026 15:46:23 +0200 Subject: [PATCH] fix(fleet): pre-configure Fleet via API during install to bypass broken setup wizard --- ct/fleet.sh | 2 ++ install/fleet-install.sh | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/ct/fleet.sh b/ct/fleet.sh index 05b7904c..491a3e09 100644 --- a/ct/fleet.sh +++ b/ct/fleet.sh @@ -58,3 +58,5 @@ msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}" +echo -e "${INFO}${YW} Admin Email:${CL} ${BGN}admin@fleet.local${CL}" +echo -e "${INFO}${YW} Admin Password:${CL} ${BGN}grep FLEET_ADMIN_PASSWORD /opt/fleet/.env${CL}" diff --git a/install/fleet-install.sh b/install/fleet-install.sh index e9e6f06c..83e1f06e 100644 --- a/install/fleet-install.sh +++ b/install/fleet-install.sh @@ -66,6 +66,31 @@ EOF systemctl enable -q --now fleet redis-server msg_ok "Created Service" +msg_info "Initializing Fleet" +FLEET_ADMIN_EMAIL="admin@fleet.local" +FLEET_ADMIN_PASS="$(openssl rand -hex 8)1!" +ELAPSED=0 +until curl -sf "http://127.0.0.1:8080/healthz" >/dev/null 2>&1; do + sleep 2 + ELAPSED=$((ELAPSED + 2)) + [[ $ELAPSED -ge 60 ]] && break +done +SETUP_RESPONSE=$(curl -s -X POST "http://127.0.0.1:8080/api/latest/fleet/setup" \ + -H "Content-Type: application/json" \ + -d "{\"admin\":{\"admin\":true,\"email\":\"${FLEET_ADMIN_EMAIL}\",\"name\":\"Admin\",\"password\":\"${FLEET_ADMIN_PASS}\"},\"org_info\":{\"org_name\":\"Fleet\",\"org_logo_url\":\"\"},\"server_url\":\"http://127.0.0.1:8080\"}") +FLEET_TOKEN=$(echo "${SETUP_RESPONSE}" | grep -o '"token":"[^"]*"' | cut -d'"' -f4) +if [[ -n "${FLEET_TOKEN}" ]]; then + curl -s -X PATCH "http://127.0.0.1:8080/api/latest/fleet/config" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer ${FLEET_TOKEN}" \ + -d "{\"server_settings\":{\"server_url\":\"http://${LOCAL_IP}:8080\"}}" >/dev/null +fi +cat <>/opt/fleet/.env +FLEET_ADMIN_EMAIL=${FLEET_ADMIN_EMAIL} +FLEET_ADMIN_PASSWORD=${FLEET_ADMIN_PASS} +EOF +msg_ok "Initialized Fleet" + motd_ssh customize cleanup_lxc