#!/bin/bash
echo "🌍 Detecting your operating system..."

OS_TYPE=$(uname | tr '[:upper:]' '[:lower:]')
HUB="https://hub.odac.run/install/step"

# Report OS detection step if code is available
if [ -n "SITEMA" ] && [ "SITEMA" != "" ]; then
    curl -sf -X POST "$HUB" -d "code=SITEMA&step=os_detect" > /dev/null 2>&1 || true
fi

if [[ "$OS_TYPE" == "linux" ]]; then
echo "🐧 Linux detected. Running installer..."
curl -fsSL https://get.odac.run/SITEMA?os=linux | sudo bash

elif [[ "$OS_TYPE" == "darwin" ]]; then
echo "🍎 macOS detected. Running installer..."
curl -fsSL https://get.odac.run/SITEMA?os=macos | sudo bash

elif [[ "$OS" == "Windows_NT" ]]; then
echo "🪟 Windows detected. Running installer..."
powershell -ExecutionPolicy Bypass -Command "iwr https://get.odac.run/SITEMA?os=windows -OutFile odac_install.ps1; ./odac_install.ps1"

else
echo "❌ Unsupported OS: $OS_TYPE"
exit 1
fi