diff --git a/scripts/redeploy.sh b/scripts/redeploy.sh new file mode 100644 index 0000000..16f3e11 --- /dev/null +++ b/scripts/redeploy.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# ============================================================================= +# ETC PRS — Redeploy Script +# Pulls latest code from Gitea, rebuilds, and reloads PM2. +# Usage: sudo bash scripts/redeploy.sh +# ============================================================================= + +set -euo pipefail + +RED='\033[0;31m'; YELLOW='\033[1;33m'; GREEN='\033[0;32m' +CYAN='\033[0;36m'; BOLD='\033[1m'; RESET='\033[0m' + +info() { echo -e "${CYAN}▸ $*${RESET}"; } +success() { echo -e "${GREEN}✓ $*${RESET}"; } +error() { echo -e "${RED}✗ $*${RESET}"; exit 1; } +divider() { echo -e "${CYAN}─────────────────────────────────────────────────${RESET}"; } + +APP_DIR="/opt/etc-prs/app" +APP_USER="prs" + +if [[ $EUID -ne 0 ]]; then + error "Run as root: sudo bash scripts/redeploy.sh" +fi + +divider +echo -e " ${BOLD}ETC PRS — Redeploy${RESET}" +divider +echo "" + +info "Pulling latest code from Gitea…" +git -C "$APP_DIR" pull + +info "Installing dependencies…" +npm --prefix "$APP_DIR" install --quiet + +info "Building…" +npm --prefix "$APP_DIR" run build + +info "Fixing ownership…" +chown -R "${APP_USER}:${APP_USER}" "$APP_DIR" + +info "Reloading PM2…" +pm2 reload etc-prs + +echo "" +success "Redeploy complete" +divider +echo "" \ No newline at end of file