#!/bin/bash
# PrimeRouter — ImageGen one-click installer (Linux).
# Run with: bash <this file>. It downloads and runs the PrimeRouter install script.
export PRIMEROUTER_AUTO_CONFIRM=1
export PRIMEROUTER_IMAGEGEN_SOURCE_BASE='https://primerouter.ai/install/skill/imagegen'
echo "PrimeRouter — ImageGen installer"
echo
tmp=$(mktemp "${TMPDIR:-/tmp}/primerouter-install.XXXXXX")
if ! curl -fsSL -o "$tmp" https://primerouter.ai/install/imagegen.sh; then
    echo
    echo "Could not download the install script. Please check your network and try again."
elif ! IFS= read -r first_line < "$tmp" || [[ "$first_line" != '#!'*bash* ]]; then
    echo
    echo "The install script is not available yet. Please try again after PrimeRouter has been updated."
elif /bin/bash "$tmp"; then
    echo
    echo "All done! You can close this window."
else
    echo
    echo "Installation failed. Please screenshot this window and contact support."
fi
rm -f "$tmp"
read -n 1 -s -r -p "Press any key to close..."
echo
