diff --git a/install.sh b/install.sh index d61e888..a019805 100755 --- a/install.sh +++ b/install.sh @@ -3,7 +3,9 @@ set -euo pipefail # ────────────────────────────────────────────── # worst-scan-web — Direct installer (no Docker) -# Usage: bash <(curl -fsSL https://gitea.cbcren.online/renato97/worst-scan-web/raw/branch/main/install.sh) +# Usage: +# screen -S worst-scan # recommended — survives SSH drops +# bash <(curl -fsSL https://gitea.cbcren.online/renato97/worst-scan-web/raw/branch/main/install.sh) # ────────────────────────────────────────────── REPO_URL="https://gitea.cbcren.online/renato97/worst-scan-web.git" @@ -134,31 +136,43 @@ fi mkdir -p "$INSTALL_DIR/data" log "Data directory ready" -# ── Build ──────────────────────────────────────── -info "Installing npm dependencies..." -cd "$INSTALL_DIR" -npm ci -log "Dependencies installed" - -info "Building Next.js app (this may take a few minutes)..." -npm run build -log "Build complete" - STANDALONE_DIR="$INSTALL_DIR/.next/standalone" -# Ensure static files are copied -if [ ! -d "$STANDALONE_DIR/.next/static" ]; then - mkdir -p "$STANDALONE_DIR/.next" - cp -r "$INSTALL_DIR/.next/static" "$STANDALONE_DIR/.next/static" +# ── Build (skip if already built) ────────────────── +if [ -f "$STANDALONE_DIR/server.js" ]; then + info "Build already exists — skipping" +else + info "Installing npm dependencies..." + cd "$INSTALL_DIR" + npm ci + log "Dependencies installed" + + info "Building Next.js app (this may take a few minutes)..." + info "Tip: run in 'screen -S worst-scan' to survive SSH drops" + npm run build + log "Build complete" + + # Ensure static files are copied + if [ ! -d "$STANDALONE_DIR/.next/static" ]; then + mkdir -p "$STANDALONE_DIR/.next" + cp -r "$INSTALL_DIR/.next/static" "$STANDALONE_DIR/.next/static" + fi + cp -r "$INSTALL_DIR/public" "$STANDALONE_DIR/public" 2>/dev/null || true fi -cp -r "$INSTALL_DIR/public" "$STANDALONE_DIR/public" 2>/dev/null || true # ── systemd service ────────────────────────────── SERVICE_NAME="worst-scan-web" APP_USER="$USER" APP_HOME="$HOME" -sudo tee "/etc/systemd/system/$SERVICE_NAME.service" > /dev/null </dev/null || true + log "systemd service $SERVICE_NAME restarted" +else + info "Creating systemd service..." + sudo tee "/etc/systemd/system/$SERVICE_NAME.service" > /dev/null <