Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

self-hosting: one install command for everyone

Carl-Gerhard Lindesvärdb8c80f4436f5
diff --git a/apps/public/content/docs/self-hosting/supporter-access-latest-docker-images.mdx b/apps/public/content/docs/self-hosting/supporter-access-latest-docker-images.mdx
index 802319589..c138c9a21 100644
--- a/apps/public/content/docs/self-hosting/supporter-access-latest-docker-images.mdx
+++ b/apps/public/content/docs/self-hosting/supporter-access-latest-docker-images.mdx
@@ -61,13 +61,13 @@ Make sure to keep your API key secure and never commit it to version control!
### Step 4: Install the CLI
-Every build comes with a matching `openpanel` CLI. Install the newest build on your server:
+On your server:
```bash
-curl -fsSL https://raw.githubusercontent.com/Openpanel-dev/openpanel/main/self-hosting/install.sh | OPENPANEL_CHANNEL=supporter sh
+curl -fsSL https://raw.githubusercontent.com/Openpanel-dev/openpanel/main/self-hosting/install.sh | sh
```
-Already have the CLI from a public release? Skip this; the next step updates it.
+Already have the `openpanel` CLI? Skip this. The next step moves it to the newest build, so it always matches your images.
### Step 5: Switch to the latest images
diff --git a/self-hosting/install.sh b/self-hosting/install.sh
index cdfe7e7a6..d92e16db4 100755
--- a/self-hosting/install.sh
+++ b/self-hosting/install.sh
@@ -7,8 +7,6 @@
# Environment:
# OPENPANEL_INSTALL_DIR Where to put the binary (default: /usr/local/bin, else ~/.local/bin)
# OPENPANEL_RELEASES_API Release feed to read (default: GitHub)
-# OPENPANEL_CHANNEL "supporter" installs the newest build (a pre-release)
-# instead of the latest public release
set -eu
RELEASES_API="${OPENPANEL_RELEASES_API:-https://api.github.com/repos/Openpanel-dev/openpanel/releases?per_page=30}"
@@ -52,15 +50,24 @@ curl -fsSL "$RELEASES_API" -o "$tmp/releases.json" || fail "could not reach $REL
# Each release object lists its tag before its assets. The newest release that
# carries this machine's binary is the one to install: every public self-hosting
# release does, and internal version tags never become releases at all.
-# Builds of main are pre-releases; only supporters want those.
-allow_prerelease=0
-[ "${OPENPANEL_CHANNEL:-}" = "supporter" ] && allow_prerelease=1
-
-tag="$(awk -v prefix="\"$TAG_PREFIX" -v name="/$asset\"" -v pre="$allow_prerelease" '
- /"tag_name":/ { split($0, parts, "\""); current = (index("\"" parts[4], prefix) == 1) ? parts[4] : "" }
- /"prerelease": *true/ && pre != 1 { current = "" }
- current != "" && /"browser_download_url":/ && index($0, name) { print current; exit }
-' "$tmp/releases.json")"
+# The newest release carrying this machine's binary. Builds of main are
+# pre-releases: skipped while a public release exists, used only before the
+# first one (supporters then move to the builds with `openpanel upgrade --supporter`).
+find_release() {
+ awk -v prefix="\"$TAG_PREFIX" -v name="/$asset\"" -v pre="$1" '
+ /"tag_name":/ { split($0, parts, "\""); current = (index("\"" parts[4], prefix) == 1) ? parts[4] : "" }
+ /"prerelease": *true/ && pre != 1 { current = "" }
+ current != "" && /"browser_download_url":/ && index($0, name) { print current; exit }
+ ' "$tmp/releases.json"
+}
+
+tag="$(find_release 0)"
+if [ -z "$tag" ]; then
+ tag="$(find_release 1)"
+ if [ -n "$tag" ]; then
+ echo "No public release yet; installing the newest build ($tag)."
+ fi
+fi
[ -n "$tag" ] || fail "no release with $asset found"
url_for() {