Last active
July 18, 2026 16:51
-
-
Save si458/2ba77d7ef99635170f6af34527772e33 to your computer and use it in GitHub Desktop.
Netbird Install on JetKVM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| set -eu | |
| main() { | |
| # Fetch latest version using wget instead of curl | |
| NETBIRD_LATEST=$(wget -qO- https://api.github.com/repos/netbirdio/netbird/releases/latest | sed -n 's/.*"tag_name": "v\([^"]*\)".*/\1/p' | head -n1) | |
| REQUESTED_VERSION="" | |
| SETUP_KEY="" | |
| AUTO_YES=false | |
| CLEAN_INSTALL=false | |
| ENABLE_SSH=false | |
| MANAGEMENT_URL="https://api.netbird.io" | |
| # Parse arguments | |
| while [ $# -gt 0 ]; do | |
| case $1 in | |
| -v | --version) | |
| REQUESTED_VERSION="$2" | |
| shift 2 | |
| ;; | |
| -k | --setup-key) | |
| SETUP_KEY="$2" | |
| shift 2 | |
| ;; | |
| -m | --management-url) | |
| MANAGEMENT_URL="$2" | |
| shift 2 | |
| ;; | |
| --enable-ssh) | |
| ENABLE_SSH=true | |
| shift | |
| ;; | |
| -y | --yes) | |
| AUTO_YES=true | |
| shift | |
| ;; | |
| -c | --clean) | |
| CLEAN_INSTALL=true | |
| shift | |
| ;; | |
| *) | |
| echo "ERROR: Unknown argument: $1" | |
| exit 1 | |
| esac | |
| done | |
| if [ -z "$SETUP_KEY" ]; then | |
| echo "ERROR: Setup key is required (use -k)" | |
| exit 1 | |
| fi | |
| export NETBIRD_VERSION="${REQUESTED_VERSION:-$NETBIRD_LATEST}" | |
| ARCHIVE="netbird_${NETBIRD_VERSION}_linux_armv6.tar.gz" | |
| ARCHIVE_URL="https://github.com/netbirdio/netbird/releases/download/v${NETBIRD_VERSION}/${ARCHIVE}" | |
| if [ "$AUTO_YES" = false ]; then | |
| echo "───────────────────────────────────────────────────────────" | |
| echo " NetBird Installation (JetKVM)" | |
| echo "───────────────────────────────────────────────────────────" | |
| echo "" | |
| echo "Version: $NETBIRD_VERSION" | |
| echo "Management URL: $MANAGEMENT_URL" | |
| echo "" | |
| fi | |
| echo "[1/4] Downloading NetBird $NETBIRD_VERSION..." | |
| # Download directly to /userdata where the local extraction logic expects it | |
| wget -qO /userdata/netbird.tar.gz "$ARCHIVE_URL" | |
| echo " Download complete" | |
| echo "[2/4] Installing NetBird..." | |
| set -e | |
| cd /userdata | |
| if [ "$CLEAN_INSTALL" = "true" ]; then | |
| echo " Removing old NetBird install..." | |
| rm -rf /userdata/netbird | |
| rm -f /etc/init.d/netbird | |
| rm -f /etc/init.d/S50netbird | |
| fi | |
| mkdir -p /userdata/netbird | |
| cd /userdata/netbird | |
| echo " Extracting package..." | |
| tar xf /userdata/netbird.tar.gz | |
| rm -f /userdata/netbird.tar.gz | |
| chmod +x ./netbird | |
| echo " Creating SSL certificate bundle..." | |
| mkdir -p /etc/ssl/certs | |
| if [ ! -f /etc/ssl/certs/ca-certificates.crt ]; then | |
| wget -O /etc/ssl/certs/ca-certificates.crt \ | |
| https://curl.se/ca/cacert.pem || true | |
| fi | |
| echo " Loading tun module..." | |
| modprobe tun || true | |
| echo " Installing NetBird service..." | |
| mkdir -p /etc/rc.d | |
| ./netbird service install || true | |
| rm -rf /etc/rc.d | |
| if [ -f /etc/init.d/netbird ]; then | |
| mv /etc/init.d/netbird /etc/init.d/S50netbird || true | |
| chmod +x /etc/init.d/S50netbird | |
| echo " Patching init script for JetKVM..." | |
| sed -i 's|/var/log|/userdata|g' /etc/init.d/S50netbird || true | |
| sed -i '/Starting \$name/a\ | |
| modprobe tun || true | |
| ' /etc/init.d/S50netbird || true | |
| fi | |
| echo " Starting NetBird daemon..." | |
| if [ -f /etc/init.d/S50netbird ]; then | |
| /etc/init.d/S50netbird start || true | |
| else | |
| nohup ./netbird service run >/userdata/netbird-service.log 2>&1 & | |
| fi | |
| echo "[3/4] Registering device..." | |
| sleep 5 | |
| NETBIRD_CMD="./netbird up --management-url \"$MANAGEMENT_URL\" --setup-key \"$SETUP_KEY\" --hostname jetkvm" | |
| if [ "$ENABLE_SSH" = "true" ]; then | |
| NETBIRD_CMD="$NETBIRD_CMD --enable-ssh" | |
| fi | |
| sh -c "$NETBIRD_CMD" >/userdata/netbird-up.log 2>&1 || true | |
| echo "[4/4] Rebooting JetKVM..." | |
| sync | |
| ( sleep 1; reboot ) & | |
| # Keep script alive until reboot completes | |
| exec tail -f /dev/null | |
| } | |
| main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment