#!/usr/bin/env bash
# Shambhavi Sovereign Labs - Sovereign Shopify Commerce Suite Installer (Linux / macOS)
set -e

BIN_NAME="sovereign-shopify"
TARGET_DIR="/usr/local/bin"
DOWNLOAD_URL="https://shambhaviailabs.com/downloads/sovereign-shopify/sovereign-shopify-linux-x64"

if [[ "$OSTYPE" == "darwin"* ]]; then
  DOWNLOAD_URL="https://shambhaviailabs.com/downloads/sovereign-shopify/sovereign-shopify-darwin-universal"
fi

echo "=========================================================="
echo "   SHAMBHAVI SOVEREIGN SHOPIFY COMMERCE SUITE INSTALLER   "
echo "   Algolia, Klaviyo & Rewind Backups Slaying Core         "
echo "=========================================================="

echo "[*] Downloading native binary from sovereign edge..."
curl -fsSL "$DOWNLOAD_URL" -o "/tmp/$BIN_NAME"
chmod +x "/tmp/$BIN_NAME"

echo "[*] Installing to $TARGET_DIR..."
sudo mv "/tmp/$BIN_NAME" "$TARGET_DIR/$BIN_NAME"

echo "[+] Successfully installed $BIN_NAME to $TARGET_DIR/$BIN_NAME"
$BIN_NAME status
