Fix 404s: serve UI templates/static from configurable ui-root, not CWD

The web UI 404'd in production because templates/static were loaded
via relative paths ("internal/ui/templates", "internal/ui/static"),
which only resolved when running from the repo checkout. systemd sets
WorkingDirectory=/var/lib/wireguard-ui-multi, so those paths never
existed there.

Add a -ui-root flag (default /usr/local/share/wireguard-ui-multi/ui),
have install.sh copy internal/ui there, and resolve templates/static
paths through it instead of hardcoded relative strings.

Also add release-binary fast path to bootstrap.sh (falls back to
source build with CGO_ENABLED=0/-trimpath if no release exists yet),
and document real hardware/build-RAM requirements in the README.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
sysops
2026-07-10 18:18:48 +02:00
co-authored by Claude Sonnet 5
parent b2b6b82f58
commit 41894e67c6
8 changed files with 91 additions and 38 deletions
+8 -1
View File
@@ -10,6 +10,8 @@ BIN_DST="/usr/local/bin/wireguard-ui-multi"
CONFIG_DIR="/etc/wireguard-ui-multi"
DATA_DIR="/var/lib/wireguard-ui-multi"
HOOKS_DIR="/etc/wireguard-manager/hooks"
UI_SRC="internal/ui"
UI_DST="/usr/local/share/wireguard-ui-multi/ui"
SERVICE_SRC="systemd/wireguard-ui-multi.service"
SERVICE_DST="/etc/systemd/system/wireguard-ui-multi.service"
@@ -22,7 +24,7 @@ if [[ ! -f "$BIN_SRC" ]]; then
if [[ -d "./cmd/wireguard-ui-multi" ]] && command -v go >/dev/null 2>&1; then
echo "Binary not found, building from source with 'go build'..."
go mod tidy
go build -o "$BIN_SRC" ./cmd/wireguard-ui-multi
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o "$BIN_SRC" ./cmd/wireguard-ui-multi
else
echo "Binary not found at $BIN_SRC and cannot build (need Go toolchain + source). Build it first, e.g.:" >&2
echo " go build -o wireguard-ui-multi ./cmd/wireguard-ui-multi" >&2
@@ -46,6 +48,11 @@ echo "Installing binary to $BIN_DST..."
cp "$BIN_SRC" "$BIN_DST"
chmod 0755 "$BIN_DST"
echo "Installing UI assets to $UI_DST..."
mkdir -p "$(dirname "$UI_DST")"
rm -rf "$UI_DST"
cp -r "$UI_SRC" "$UI_DST"
echo "Installing systemd unit to $SERVICE_DST..."
cp "$SERVICE_SRC" "$SERVICE_DST"
systemctl daemon-reload
+1 -1
View File
@@ -162,7 +162,7 @@ pct exec "$VMID" -- bash -c "
set -e
cd /opt/wireguard-ui-multi-src
go mod tidy
go build -o wireguard-ui-multi ./cmd/wireguard-ui-multi
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o wireguard-ui-multi ./cmd/wireguard-ui-multi
bash scripts/install.sh
"