#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")/.."

echo "==> VidNest cPanel install"

if [ ! -f .env ]; then
  cp .env.cpanel .env
  echo "Created .env from .env.cpanel — edit WORKER_URL and API_URL before restart"
fi

if [ ! -d node_modules/express ]; then
  echo "==> node_modules missing — running npm install..."
  npm install --production --no-audit --no-fund
else
  echo "==> node_modules OK (bundled in zip)"
fi

echo "==> Done. Restart Node.js app in cPanel."
