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
+25
-14
@@ -1,10 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# One-shot bootstrap installer for wireguard-ui-multi.
|
||||
# Downloads source, builds it, and runs the native installer - end to end,
|
||||
# no pre-existing checkout required.
|
||||
# One-shot bootstrap installer for wireguard-ui-multi (fork of
|
||||
# ngoduykhanh/wireguard-ui). Downloads source, builds frontend assets +
|
||||
# Go binary, and runs the native installer - end to end, no pre-existing
|
||||
# checkout required.
|
||||
#
|
||||
# Usage (on target Debian/Ubuntu host, as root):
|
||||
# curl -fsSL https://gitea.perlbach24.de/scripte/wireguard-ui-multi/raw/branch/main/scripts/bootstrap.sh | bash
|
||||
# curl -fsSL https://gitea.perlbach24.de/scripte/wireguard-ui-multi/raw/branch/main/bootstrap.sh | bash
|
||||
# or:
|
||||
# bash bootstrap.sh [--ref main] [--src-dir /opt/wireguard-ui-multi-src]
|
||||
set -euo pipefail
|
||||
@@ -36,10 +37,15 @@ if [[ "$(id -u)" -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Installing base dependencies (git, wireguard-tools, nftables, curl, ca-certificates)..."
|
||||
echo "Installing base dependencies (git, wireguard-tools, nftables, curl, ca-certificates, nodejs, npm)..."
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update
|
||||
apt-get install -y git wireguard-tools nftables curl ca-certificates
|
||||
apt-get install -y git wireguard-tools nftables curl ca-certificates nodejs npm
|
||||
|
||||
if ! command -v yarn >/dev/null 2>&1; then
|
||||
echo "Installing yarn..."
|
||||
npm install -g yarn
|
||||
fi
|
||||
|
||||
export PATH="/usr/local/go/bin:/usr/local/bin:$PATH"
|
||||
ARCH="$(dpkg --print-architecture)"
|
||||
@@ -58,15 +64,15 @@ cd "$SRC_DIR"
|
||||
|
||||
BIN_READY=0
|
||||
if [[ "$SKIP_RELEASE" -eq 0 ]]; then
|
||||
RELEASE_ASSET_URL="${RELEASE_BASE_URL}/${REF}/wireguard-ui-multi-linux-${ARCH}"
|
||||
RELEASE_ASSET_URL="${RELEASE_BASE_URL}/${REF}/wireguard-ui-linux-${ARCH}"
|
||||
echo "Trying prebuilt release binary: $RELEASE_ASSET_URL"
|
||||
if curl -fsSL "$RELEASE_ASSET_URL" -o wireguard-ui-multi.tmp; then
|
||||
mv wireguard-ui-multi.tmp wireguard-ui-multi
|
||||
chmod 0755 wireguard-ui-multi
|
||||
if curl -fsSL "$RELEASE_ASSET_URL" -o wireguard-ui.tmp; then
|
||||
mv wireguard-ui.tmp wireguard-ui
|
||||
chmod 0755 wireguard-ui
|
||||
BIN_READY=1
|
||||
echo "Using prebuilt release binary (skipped local Go build)."
|
||||
echo "Using prebuilt release binary (skipped local build)."
|
||||
else
|
||||
rm -f wireguard-ui-multi.tmp
|
||||
rm -f wireguard-ui.tmp
|
||||
echo "No prebuilt release binary available, building from source instead."
|
||||
fi
|
||||
fi
|
||||
@@ -91,9 +97,14 @@ if [[ "$BIN_READY" -eq 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Building wireguard-ui-multi from source..."
|
||||
if [[ ! -d assets/dist ]]; then
|
||||
echo "Building frontend assets (yarn)..."
|
||||
bash prepare_assets.sh
|
||||
fi
|
||||
|
||||
echo "Building wireguard-ui from source..."
|
||||
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 .
|
||||
fi
|
||||
|
||||
echo "Running native installer..."
|
||||
|
||||
Reference in New Issue
Block a user