#!/bin/bash
# Deploy rfoof on GoDaddy shared cPanel hosting.
# Run this via SSH after cloning/pulling the code.

set -euo pipefail

APP_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$APP_DIR"

echo "→ Installing requirements"
pip3 install --user --upgrade pip
pip3 install --user -r requirements.txt

if [ ! -f .env ]; then
    echo "❌ Missing .env. Copy .env.cpanel to .env and edit it first."
    exit 1
fi

echo "→ Running migrations"
python3 manage.py migrate --noinput

echo "→ Collecting static files"
python3 manage.py collectstatic --noinput

echo "→ Reloading Passenger"
mkdir -p tmp
touch tmp/restart.txt

echo "✅ Deployed"
