ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
fix(agent): target the serverkit-agent repo and its vX.Y.Z releases
Juan Denis6d3250704d15
diff --git a/SECURITY.md b/SECURITY.mdindex 437a0cc9..91353743 100644--- a/SECURITY.md+++ b/SECURITY.md@@ -10,7 +10,9 @@ release line and the `main` branch.| 1.6.x | ✅ || < 1.6 | ❌ (please upgrade) |-The **agent** is versioned independently (`agent-vX.Y.Z`); always run a recent+The **agent** ships from its own repository, `jhd3197/serverkit-agent`, and is+versioned independently (`vX.Y.Z` — it used `agent-vX.Y.Z` while it lived in this+monorepo); always run a recentagent build, as several Windows service and credential-handling fixes landed inthe 1.6.x line.diff --git a/scripts/install.ps1 b/scripts/install.ps1index f9bc2660..15624043 100644--- a/scripts/install.ps1+++ b/scripts/install.ps1@@ -47,7 +47,9 @@ $InstallDir = "$env:ProgramFiles\ServerKit"$ConfigDir = "$env:ProgramData\ServerKit\Agent"$LogDir = "$env:ProgramData\ServerKit\Agent\logs"$ServiceName = "ServerKitAgent"-$GitHubRepo = "jhd3197/ServerKit"+# The agent has its own repo and its own vX.Y.Z releases; it no longer ships+# from the panel monorepo. Keep in step with scripts/install.sh.+$GitHubRepo = "jhd3197/serverkit-agent"$AgentBinary = "serverkit-agent.exe"# Colors@@ -85,7 +87,10 @@ function Get-LatestVersion {try {$releases = Invoke-RestMethod -Uri "https://api.github.com/repos/$GitHubRepo/releases" -Method Getforeach ($release in $releases) {- if ($release.tag_name -match "^agent-v(.+)$") {+ # Plain vX.Y.Z in the dedicated agent repo (it used to be+ # `agent-v*` back when the agent shipped from the panel monorepo).+ # Requiring a digit skips the malformed release tagged just "v".+ if ($release.tag_name -match "^v(\d.*)$") {$script:Version = $Matches[1]Write-ColorOutput "Latest version: v$Version" "Info"return@@ -107,7 +112,7 @@ function Install-Agent {$tempDir = Join-Path $env:TEMP "serverkit-install-$(Get-Random)"New-Item -ItemType Directory -Path $tempDir -Force | Out-Null- $downloadUrl = "https://github.com/$GitHubRepo/releases/download/agent-v$Version/serverkit-agent-$Version-windows-amd64.zip"+ $downloadUrl = "https://github.com/$GitHubRepo/releases/download/v$Version/serverkit-agent-$Version-windows-amd64.zip"$archivePath = Join-Path $tempDir "serverkit-agent.zip"try {diff --git a/scripts/install.sh b/scripts/install.shindex c715e254..0df4d719 100644--- a/scripts/install.sh+++ b/scripts/install.sh@@ -3,7 +3,11 @@# ServerKit Agent Installation Script## Usage:-# curl -fsSL https://your-serverkit.com/install.sh | sudo bash -s -- --token "TOKEN" --server "URL"+# curl -fsSL https://your-serverkit.com/install.sh -o /tmp/serverkit-agent-install.sh \+# && sudo bash /tmp/serverkit-agent-install.sh --token "TOKEN" --server "URL"+#+# Deliberately not `curl … | sudo bash`: a pipeline reports bash's exit status,+# not curl's, so a failed download exits 0 having installed nothing (issue #101).## Options:# --token, -t Registration token (required)@@ -35,7 +39,12 @@ INSTALL_DIR="/usr/local/bin"CONFIG_DIR="/etc/serverkit-agent"LOG_DIR="/var/log/serverkit-agent"SERVICE_USER="serverkit-agent"-GITHUB_REPO="jhd3197/ServerKit"+# The agent lives in its own repo and publishes its own releases, tagged plain+# `vX.Y.Z`. It used to live in the panel monorepo under `agent-v*` tags, and this+# script was never updated when it moved -- so every download 404'd against a tag+# scheme that no longer exists anywhere. Keep this in step with+# serverkit-agent/install.sh; the panel serves THIS copy.+GITHUB_REPO="jhd3197/serverkit-agent"AGENT_BINARY="serverkit-agent"# Arguments@@ -87,7 +96,8 @@ show_help() {echo " --help, -h Show this help message"echo ""echo "Example:"- echo " curl -fsSL https://your-serverkit.com/install.sh | sudo bash -s -- \\"+ echo " curl -fsSL https://your-serverkit.com/install.sh -o /tmp/serverkit-agent-install.sh \\"+ echo " && sudo bash /tmp/serverkit-agent-install.sh \\"echo " --token 'sk_reg_xxx' \\"echo " --server 'https://your-serverkit.com'"exit 0@@ -195,14 +205,18 @@ get_latest_version() {log_info "Fetching latest version..."- # Agent tags share this repo with panel releases, which can push every- # agent-v* tag off the first page — so page through instead of trusting- # the default (30-entry) first page. Capped at 3 pages of 100.+ # Every release in the agent repo is an agent release, so the first vX.Y.Z+ # tag is the one we want. The paging kept from the monorepo era costs one+ # extra request at most and covers a repo with many pre-release tags.+ #+ # The `[0-9]` is load-bearing: the repo carries a malformed release literally+ # tagged "v", which would otherwise parse to an empty VERSION and send the+ # download at .../releases/download/v/serverkit-agent--linux-amd64.tar.gz.local page releasesVERSION=""for page in 1 2 3; doreleases=$(curl -fsSL "https://api.github.com/repos/${GITHUB_REPO}/releases?per_page=100&page=${page}") || break- VERSION=$(printf '%s\n' "$releases" | grep -o '"tag_name": *"agent-v[^"]*"' | head -1 | sed -e 's/.*agent-v//' -e 's/"$//') || true+ VERSION=$(printf '%s\n' "$releases" | grep -o '"tag_name": *"v[0-9][^"]*"' | head -1 | sed -e 's/.*"v//' -e 's/"$//') || true[[ -n "$VERSION" ]] && break# A page with no tags at all means the release list is exhausted.printf '%s' "$releases" | grep -q '"tag_name"' || break@@ -219,7 +233,7 @@ get_latest_version() {# but-mismatching checksum is a hard failure.verify_checksum() {local tmp_dir="$1" asset_name="$2"- local checksums_url="https://github.com/${GITHUB_REPO}/releases/download/agent-v${VERSION}/checksums.txt"+ local checksums_url="https://github.com/${GITHUB_REPO}/releases/download/v${VERSION}/checksums.txt"if ! command -v sha256sum &> /dev/null; thenlog_warn "sha256sum not available — skipping checksum verification"@@ -248,7 +262,7 @@ download_agent() {log_info "Downloading ServerKit Agent v${VERSION}..."ASSET_NAME="serverkit-agent-${VERSION}-linux-${ARCH}.tar.gz"- DOWNLOAD_URL="https://github.com/${GITHUB_REPO}/releases/download/agent-v${VERSION}/${ASSET_NAME}"+ DOWNLOAD_URL="https://github.com/${GITHUB_REPO}/releases/download/v${VERSION}/${ASSET_NAME}"TMP_DIR=$(mktemp -d)ARCHIVE="${TMP_DIR}/${ASSET_NAME}"diff --git a/scripts/test/test_agent_install.sh b/scripts/test/test_agent_install.shindex 195a6e73..9e5a4a13 100644--- a/scripts/test/test_agent_install.sh+++ b/scripts/test/test_agent_install.sh@@ -70,61 +70,107 @@ set +e +u # hand control back to the harness; tests re-arm set -e per subshellprintf '\nagent install.sh unit tests\n\n'# ---------------------------------------------------------------------------# T1 — paged version discovery. The repo is shared with panel releases, so a-# first page full of v1.7.x tags must NOT break enrollment: discovery has to-# request per_page=100 and keep paging until it finds an agent-v* tag.+# T0 — release-coordinate contract. This is the test whose absence let the+# installer rot: the agent moved to its own repo (plain vX.Y.Z tags) and this+# script kept asking jhd3197/ServerKit for `agent-v*` tags that exist nowhere,+# so every enrollment 404'd at the download step. The old T1/T2 below actively+# encoded the dead scheme with agent-v* fixtures and stayed green throughout.# ---------------------------------------------------------------------------{- printf '['- for i in $(seq 1 30); do printf '{"tag_name": "v1.7.%s"},' "$i"; done- printf '{"tag_name": "v1.7.99"}]'-} > "$FIXTURES/releases_page_1.json"-printf '[{"tag_name": "v1.6.0"},{"tag_name": "agent-v0.3.2"},{"tag_name": "agent-v0.3.1"}]' \- > "$FIXTURES/releases_page_2.json"+repo_default="$(grep -m1 '^GITHUB_REPO=' "$INSTALL_SH" | cut -d'"' -f2)"+if [ "$repo_default" = "jhd3197/serverkit-agent" ]; then+ ok "GITHUB_REPO points at the repo that publishes agent binaries"+else+ bad "GITHUB_REPO=[$repo_default]; agent releases live in jhd3197/serverkit-agent"+fi+if grep -qE 'releases/download/v\$\{VERSION\}/\$\{ASSET_NAME\}' "$INSTALL_SH"; then+ ok "download URL uses the published /v\${VERSION}/ tag scheme"+else+ bad "download URL does not use /v\${VERSION}/: $(grep -n 'releases/download' "$INSTALL_SH" | tr '\n' ' ')"+fi+if grep -q 'agent-v' "$INSTALL_SH"; then+ # A prose mention in a comment is fine; a URL or a tag filter is not.+ if grep 'agent-v' "$INSTALL_SH" | grep -qvE '^\s*#'; then+ bad "live agent-v reference remains: $(grep -n 'agent-v' "$INSTALL_SH" | grep -vE ':\s*#' | tr '\n' ' ')"+ else+ ok "no live agent-v* references remain (comments only)"+ fi+else+ ok "no agent-v* references remain"+fi++# --------------------------------------------------------------------------+# T1 — version discovery picks the newest vX.Y.Z, and must SKIP the malformed+# release tagged literally "v" that sits in the agent repo's release list.+# Without the digit guard that tag yields an empty VERSION and the installer+# builds .../releases/download/v/serverkit-agent--linux-amd64.tar.gz.+# --------------------------------------------------------------------------+printf '[{"tag_name": "v"},{"tag_name": "v1.2.0"},{"tag_name": "v1.1.0"}]' \+ > "$FIXTURES/releases_page_1.json": > "$CURL_LOG"if ! got="$(# && chain: set -e is suppressed inside an if-condition substitution, so# only an explicit chain makes get_latest_version's status gate the result.set -Eeuo pipefail- VERSION="latest"; SERVERKIT_AGENT_VERSION=""; GITHUB_REPO="jhd3197/ServerKit"+ VERSION="latest"; SERVERKIT_AGENT_VERSION=""; GITHUB_REPO="jhd3197/serverkit-agent"get_latest_version >/dev/null \&& printf '%s' "$VERSION")"; then- bad "paged discovery aborted under set -Eeuo pipefail"-elif [ "$got" = "0.3.2" ]; then- ok "paged discovery finds agent-v0.3.2 on page 2 behind a page of panel tags"+ bad "version discovery aborted under set -Eeuo pipefail"+elif [ "$got" = "1.2.0" ]; then+ ok "discovery picks the newest vX.Y.Z and skips the malformed \"v\" tag"else- bad "paged discovery: VERSION=[$got], want 0.3.2"+ bad "discovery: VERSION=[$got], want 1.2.0"fiif grep -q 'per_page=100' "$CURL_LOG"; thenok "release requests ask GitHub for per_page=100"elsebad "per_page=100 missing from release requests"fi-if grep -q 'page=2' "$CURL_LOG" && ! grep -q 'page=3' "$CURL_LOG"; then- ok "discovery pages forward and stops once a tag is found (no page=3 request)"+if ! grep -q 'page=2' "$CURL_LOG"; then+ ok "discovery stops once a tag is found (no page=2 request)"elsebad "unexpected page sequence: $(tr '\n' ' ' < "$CURL_LOG")"fi# ---------------------------------------------------------------------------# T2 — discovery must fail LOUDLY (exit 1), not silently, when no agent-v*-# tag exists on any page; and an empty page ends the paging early.+# T1b — paging still works when page 1 holds nothing usable.+# --------------------------------------------------------------------------+mkdir -p "$WORK/fx1b"+printf '[{"tag_name": "v"},{"tag_name": "nightly"}]' > "$WORK/fx1b/releases_page_1.json"+printf '[{"tag_name": "v0.9.1"}]' > "$WORK/fx1b/releases_page_2.json"+: > "$CURL_LOG"+if ! got="$(+ set -Eeuo pipefail+ FIXTURES="$WORK/fx1b"+ VERSION="latest"; SERVERKIT_AGENT_VERSION=""; GITHUB_REPO="jhd3197/serverkit-agent"+ get_latest_version >/dev/null \+ && printf '%s' "$VERSION"+)"; then+ bad "paged discovery aborted under set -Eeuo pipefail"+elif [ "$got" = "0.9.1" ]; then+ ok "discovery pages forward past a page with no usable tags"+else+ bad "paged discovery: VERSION=[$got], want 0.9.1"+fi++# --------------------------------------------------------------------------+# T2 — discovery must fail LOUDLY (exit 1), not silently, when no vX.Y.Z tag+# exists on any page; and an empty page ends the paging early.# --------------------------------------------------------------------------mkdir -p "$WORK/fx2"-printf '[{"tag_name": "v1.7.0"}]' > "$WORK/fx2/releases_page_1.json"+printf '[{"tag_name": "v"},{"tag_name": "nightly"}]' > "$WORK/fx2/releases_page_1.json"printf '[]' > "$WORK/fx2/releases_page_2.json": > "$CURL_LOG"if (set -Eeuo pipefailFIXTURES="$WORK/fx2"- VERSION="latest"; SERVERKIT_AGENT_VERSION=""; GITHUB_REPO="jhd3197/ServerKit"+ VERSION="latest"; SERVERKIT_AGENT_VERSION=""; GITHUB_REPO="jhd3197/serverkit-agent"get_latest_version) >/dev/null 2>&1; then- bad "discovery must exit non-zero when no agent-v tag exists"+ bad "discovery must exit non-zero when no vX.Y.Z tag exists"else- ok "discovery fails loudly (exit 1) when no agent-v tag exists on any page"+ ok "discovery fails loudly (exit 1) when no vX.Y.Z tag exists on any page"fiif grep -q 'page=2' "$CURL_LOG" && ! grep -q 'page=3' "$CURL_LOG"; thenok "an empty release page stops the paging (no page=3 request)"@@ -132,6 +178,24 @@ elsebad "empty-page stop broken: $(tr '\n' ' ' < "$CURL_LOG")"fi+# --------------------------------------------------------------------------+# T2b — verify_checksum must fetch checksums.txt from the /v${VERSION}/ tag.+# Exercised for real through the curl stub, so a URL regression shows up here+# and not only in the static grep above.+# --------------------------------------------------------------------------+: > "$CURL_LOG"+(+ set +e+ t="$WORK/ck-url"; mkdir -p "$t"+ VERSION="1.2.0"; GITHUB_REPO="jhd3197/serverkit-agent"+ verify_checksum "$t" "serverkit-agent-1.2.0-linux-amd64.tar.gz"+) >/dev/null 2>&1+if grep -q 'serverkit-agent/releases/download/v1.2.0/checksums.txt' "$CURL_LOG"; then+ ok "checksums.txt is fetched from <agent repo>/releases/download/v1.2.0/"+else+ bad "wrong checksums URL: $(tr '\n' ' ' < "$CURL_LOG")"+fi+# --------------------------------------------------------------------------# T3 — the panel-injected version short-circuits GitHub discovery entirely,# and an explicit --version is left untouched.@@ -139,7 +203,7 @@ fi: > "$CURL_LOG"if ! got="$(set -Eeuo pipefail- VERSION="latest"; SERVERKIT_AGENT_VERSION="9.9.9"; GITHUB_REPO="jhd3197/ServerKit"+ VERSION="latest"; SERVERKIT_AGENT_VERSION="9.9.9"; GITHUB_REPO="jhd3197/serverkit-agent"get_latest_version >/dev/null \&& printf '%s' "$VERSION")"; then@@ -153,7 +217,7 @@ fi: > "$CURL_LOG"if ! got="$(set -Eeuo pipefail- VERSION="1.2.3"; SERVERKIT_AGENT_VERSION=""; GITHUB_REPO="jhd3197/ServerKit"+ VERSION="1.2.3"; SERVERKIT_AGENT_VERSION=""; GITHUB_REPO="jhd3197/serverkit-agent"get_latest_version >/dev/null \&& printf '%s' "$VERSION")"; then@@ -177,7 +241,7 @@ if command -v sha256sum >/dev/null 2>&1; thenprintf '%s %s\n' "$sha" "$asset" > "$FIXTURES/checksums.txt"if (set -Eeuo pipefail- VERSION="0.3.2"; GITHUB_REPO="jhd3197/ServerKit"+ VERSION="0.3.2"; GITHUB_REPO="jhd3197/serverkit-agent"verify_checksum "$t" "$asset") >/dev/null 2>&1; thenok "verify_checksum passes on a matching sha256"@@ -192,7 +256,7 @@ if command -v sha256sum >/dev/null 2>&1; then"$asset" > "$FIXTURES/checksums.txt"if (set -Eeuo pipefail- VERSION="0.3.2"; GITHUB_REPO="jhd3197/ServerKit"+ VERSION="0.3.2"; GITHUB_REPO="jhd3197/serverkit-agent"verify_checksum "$t" "$asset") >/dev/null 2>&1; thenbad "verify_checksum must HALT on a checksum mismatch"@@ -205,7 +269,7 @@ if command -v sha256sum >/dev/null 2>&1; thenrm -f "$FIXTURES/checksums.txt"if (set -Eeuo pipefail- VERSION="0.3.2"; GITHUB_REPO="jhd3197/ServerKit"+ VERSION="0.3.2"; GITHUB_REPO="jhd3197/serverkit-agent"verify_checksum "$t" "$asset") >/dev/null 2>&1; thenok "missing checksums.txt is best-effort (warn + continue)"@@ -218,7 +282,7 @@ if command -v sha256sum >/dev/null 2>&1; thenprintf '%s some-other-file.tar.gz\n' "$sha" > "$FIXTURES/checksums.txt"if (set -Eeuo pipefail- VERSION="0.3.2"; GITHUB_REPO="jhd3197/ServerKit"+ VERSION="0.3.2"; GITHUB_REPO="jhd3197/serverkit-agent"verify_checksum "$t" "$asset") >/dev/null 2>&1; thenok "checksums.txt without our asset entry is best-effort (warn + continue)"