Files
nixpanel-server/scripts/update.sh
T
NixReaper 92d08d7b79 feat: rename WHM→NixServer, cPanel→NixClient, bump v0.2.0
- Rename frontend workspaces: whm/ → nixserver/, cpanel/ → nixclient/
- Rename server route dirs: routes/whm/ → routes/nixserver/, routes/cpanel/ → routes/nixclient/
- Update all API prefixes: /api/whm → /api/nixserver, /api/cpanel → /api/nixclient
- Rename env vars: WHM_PORT → NIXSERVER_PORT, CPANEL_PORT → NIXCLIENT_PORT
- Update config properties: whmPort → nixserverPort, cpanelPort → nixclientPort
- Update all UI labels, login pages, sidebar branding, and error messages
- Update installer and update scripts to match new names
- Add cpanel email route (missing from initial scaffold)
- Add .gitattributes to enforce LF line endings
- Bump version to 0.2.0 across all package.json files
2026-04-05 10:54:15 -05:00

50 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# NixPanel updater — pulls latest code and rebuilds
set -euo pipefail
RED='\033[0;31m'; GREEN='\033[0;32m'; CYAN='\033[0;36m'; BOLD='\033[1m'; RESET='\033[0m'
info() { echo -e "${CYAN}[INFO]${RESET} $*"; }
success() { echo -e "${GREEN}[OK]${RESET} $*"; }
error() { echo -e "${RED}[ERROR]${RESET} $*" >&2; exit 1; }
step() { echo -e "\n${BOLD}${CYAN}━━━ $* ━━━${RESET}"; }
[[ $EUID -ne 0 ]] && error "Must be run as root"
INSTALL_DIR="${1:-/opt/nixpanel}"
[[ -d "$INSTALL_DIR/.git" ]] || error "NixPanel not found at $INSTALL_DIR"
step "Pulling latest code"
git -C "$INSTALL_DIR" pull --ff-only
success "Code updated"
step "Installing dependencies"
cd "$INSTALL_DIR"
npm install --workspaces --include-workspace-root --silent
success "Dependencies ready"
step "Running migrations"
cd "$INSTALL_DIR/server"
npx prisma generate --silent
npx prisma migrate deploy
success "Migrations applied"
step "Rebuilding frontends"
cd "$INSTALL_DIR"
npm run build --workspace=nixserver --silent
npm run build --workspace=nixclient --silent
success "Frontends rebuilt"
step "Rebuilding server"
cd "$INSTALL_DIR/server"
npm run build --silent 2>/dev/null || npx tsc 2>/dev/null || true
success "Server rebuilt"
step "Restarting service"
systemctl restart nixpanel
sleep 3
systemctl is-active nixpanel && success "nixpanel restarted" || error "nixpanel failed to start — check: journalctl -u nixpanel -n 50"
echo ""
echo -e "${BOLD}${GREEN}NixPanel updated successfully!${RESET}"
echo ""