-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefresh.sh
More file actions
executable file
·29 lines (24 loc) · 960 Bytes
/
Copy pathrefresh.sh
File metadata and controls
executable file
·29 lines (24 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash
# Fetch latest code (HTML, JS, CSS) without recompiling.
# Exit on error, undefined variables, and pipe failures
set -euo pipefail
# Configuration
APP_NAME="chatserver"
INSTALL_DIR="/opt/$APP_NAME"
# Logging helpers
log() { printf '\033[1;34m→ %s\033[0m\n' "$*"; }
ok() { printf '\033[1;32m✓ %s\033[0m\n' "$*"; }
fail() { printf '\033[1;31m✗ %s\033[0m\n' "$*" >&2; exit 1; }
# Require root and a valid install directory
[[ "$(id -u)" -eq 0 ]] || fail "This script must be run as root"
[[ -d "$INSTALL_DIR" ]] || fail "Install directory $INSTALL_DIR not found"
# Leaf templates and static files are served from disk — no restart needed
log "Fetching latest code"
cd "$INSTALL_DIR"
git config --global --add safe.directory "$INSTALL_DIR"
git fetch origin
if ! git merge --ff-only origin/main 2>/dev/null; then
log "Fast-forward failed, resetting to origin/main"
git reset --hard origin/main
fi
ok "Repository updated"