#!/bin/bash

# Quick Deploy Script for Church Song Lyric System
# Run this after transferring files to Ubuntu server

set -e

INSTALL_DIR="/var/www/church-songlyric"

echo "=========================================="
echo "Church Song Lyric - Quick Deploy"
echo "=========================================="
echo ""

# Rebuild frontend
echo "Building frontend..."
cd "$INSTALL_DIR/frontend"
npm install
npm run build

# Restart backend service
echo "Restarting backend service..."
sudo systemctl restart church-songlyric-backend

# Reload Nginx
echo "Reloading Nginx..."
sudo systemctl reload nginx

# Check status
echo ""
echo "=========================================="
echo "Service Status:"
echo "=========================================="
sudo systemctl status church-songlyric-backend --no-pager -l
echo ""
sudo systemctl status nginx --no-pager -l

echo ""
echo "=========================================="
echo "Deployment complete!"
echo "=========================================="
echo ""
echo "View logs:"
echo "  sudo journalctl -u church-songlyric-backend -f"
echo ""
