diff --git a/ai-hub/app/core/templates/provisioning/provision.sh.j2 b/ai-hub/app/core/templates/provisioning/provision.sh.j2 index 2bf46e8..d7165b4 100644 --- a/ai-hub/app/core/templates/provisioning/provision.sh.j2 +++ b/ai-hub/app/core/templates/provisioning/provision.sh.j2 @@ -36,17 +36,31 @@ {{ config_yaml }} EOF -# 3. Download standalone binary -echo "[*] Downloading unified binary core for $BIN_ARCH..." +# 3. Download standalone binary or Source fallback +echo "[*] Downloading agent core..." INSTALLER_URL="{{ base_url }}/api/v1/agent/binary/$BIN_ARCH" -if ! curl -sSLf "$INSTALLER_URL" -o cortex-agent; then - echo "❌ Failed to download binary for architecture: $BIN_ARCH from $INSTALLER_URL" - echo "Fallback: Try the python headless installer instead: curl -sSL {{ base_url }}/api/v1/nodes/provision/{{ node_id }} | python3" - exit 1 + +if curl -sSLf "$INSTALLER_URL" -o cortex-agent; then + echo "✅ Downloaded standalone binary for $BIN_ARCH" + chmod +x cortex-agent + BINARY_PATH="$INSTALL_DIR/cortex-agent" +else + echo "⚠️ Standalone binary for $BIN_ARCH was not found (404). Falling back to Source + Venv..." + SOURCE_URL="{{ base_url }}/api/v1/nodes/provision/{{ node_id }}?token={{ invite_token }}" + echo "[*] Downloading bootstrap source installer..." + + # Use python to run the legacy bootstrap installer which handles platform-native installs + if ! curl -sSLf "$SOURCE_URL" | python3; then + echo "❌ Provisioning failed via python bootstrap fallback." + exit 1 + fi + # If the python script ran correctly, it would have already handled the rest of the install! + echo "✅ Python-based bootstrap provisioning successful!" + exit 0 fi -chmod +x cortex-agent # 4. Bootstrap daemon installation +BINARY_PATH="$INSTALL_DIR/cortex-agent" echo "[*] Bootstrapping agent daemon..." # Run the standalone binary with the install-daemon flags (must implement in main.py) # Or we can just run it in the background if systemd is unavailable