#!/data/data/com.termux/files/usr/bin/bash
# Iris helper for Termux (Android).
#
#   pkg install nodejs python ffmpeg
#   pip install -U yt-dlp
#   bash iris-termux.sh
#
# Then open iris.devilabs.dev in the phone browser and paste the code this
# prints. Keep Termux running in the background while you use the site.

set -u

BOLD='\033[1m'; CYAN='\033[0;36m'; DIM='\033[2m'; RED='\033[0;31m'; NC='\033[0m'

echo ""
echo -e "${CYAN}${BOLD}  I R I S   helper (termux)${NC}"
echo -e "${DIM}  keep this running while you use the site${NC}"
echo ""

missing=""
command -v node  >/dev/null 2>&1 || missing="$missing nodejs"
command -v yt-dlp >/dev/null 2>&1 || missing="$missing yt-dlp"
command -v ffmpeg >/dev/null 2>&1 || missing="$missing ffmpeg"

if [ -n "$missing" ]; then
  echo -e "${RED}  Missing:$missing${NC}"
  echo ""
  echo "  pkg install nodejs ffmpeg python"
  echo "  pip install -U yt-dlp"
  echo ""
  exit 1
fi

# Termux kills background processes aggressively; keep the screen awake.
command -v termux-wake-lock >/dev/null 2>&1 && termux-wake-lock

cd "$(dirname "$0")" || exit 1
exec node server.mjs
