Adapt installers to upstream wireguard-ui build (Go+embed, yarn assets)
Upstream builds a single static binary (main.go at repo root, no cmd/... subpackage) that go:embeds templates/ and assets/ at compile time, and uses a relative ./db directory (jsondb) instead of SQLite - so WorkingDirectory in the systemd unit now matters for the DB path, not for template/static serving like before. Frontend assets (admin-lte, jquery plugins) need yarn + prepare_assets.sh before go build, so all installers now also install nodejs/npm/yarn and run prepare_assets.sh when assets/dist is missing or package.json changed. Binary is now literally named "wireguard-ui" (matches upstream), listens on 0.0.0.0:5000 by default. systemd unit rewritten accordingly with WorkingDirectory=/var/lib/wireguard-ui-multi. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
94f0e69676
commit
e5c0a5888f
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Updates an existing wireguard-ui-multi installation: pulls the latest
|
||||
# source, rebuilds, reinstalls the binary/unit, and restarts the service.
|
||||
# source, rebuilds frontend assets + binary if needed, reinstalls, and
|
||||
# restarts the service.
|
||||
#
|
||||
# Usage (as root):
|
||||
# cd /opt/wireguard-ui-multi-src && ./update.sh
|
||||
@@ -40,9 +41,11 @@ fi
|
||||
echo "Fetching latest $REF..."
|
||||
git -C "$SRC_DIR" fetch --depth 1 origin "$REF"
|
||||
BEFORE="$(git -C "$SRC_DIR" rev-parse HEAD)"
|
||||
PREV_PACKAGE_JSON_HASH="$(sha256sum "$SRC_DIR/package.json" 2>/dev/null | awk '{print $1}')"
|
||||
git -C "$SRC_DIR" checkout "$REF"
|
||||
git -C "$SRC_DIR" reset --hard "origin/$REF"
|
||||
AFTER="$(git -C "$SRC_DIR" rev-parse HEAD)"
|
||||
NEW_PACKAGE_JSON_HASH="$(sha256sum "$SRC_DIR/package.json" 2>/dev/null | awk '{print $1}')"
|
||||
|
||||
if [[ "$BEFORE" == "$AFTER" ]]; then
|
||||
echo "Already up to date ($AFTER)."
|
||||
@@ -50,10 +53,20 @@ else
|
||||
echo "Updated $BEFORE -> $AFTER"
|
||||
fi
|
||||
|
||||
echo "Rebuilding..."
|
||||
cd "$SRC_DIR"
|
||||
|
||||
if [[ "$PREV_PACKAGE_JSON_HASH" != "$NEW_PACKAGE_JSON_HASH" ]] || [[ ! -d assets/dist ]]; then
|
||||
echo "Frontend dependencies changed (or assets missing), rebuilding assets..."
|
||||
if ! command -v yarn >/dev/null 2>&1; then
|
||||
echo "yarn not found; install nodejs/npm/yarn first (see bootstrap.sh)." >&2
|
||||
exit 1
|
||||
fi
|
||||
bash prepare_assets.sh
|
||||
fi
|
||||
|
||||
echo "Rebuilding binary..."
|
||||
go mod tidy
|
||||
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o wireguard-ui-multi ./cmd/wireguard-ui-multi
|
||||
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o wireguard-ui .
|
||||
|
||||
echo "Reinstalling..."
|
||||
bash scripts/install.sh
|
||||
|
||||
Reference in New Issue
Block a user