Skip to content

Instantly share code, notes, and snippets.

@tgrushka
Last active March 26, 2025 20:30
Show Gist options
  • Save tgrushka/cc2d46e7a5e3d3f9b534e82878e5c3fc to your computer and use it in GitHub Desktop.
Save tgrushka/cc2d46e7a5e3d3f9b534e82878e5c3fc to your computer and use it in GitHub Desktop.
Headscale Install Debian
#!/bin/bash
set -euo pipefail
apt-get install -y jq || true
# Check required commands
command -v curl >/dev/null || { echo "Error: curl required" >&2; exit 1; }
command -v jq >/dev/null || { echo "Error: jq required" >&2; exit 1; }
# Create temp directory with proper permissions
TMPDIR=$(mktemp -d)
chmod 755 "$TMPDIR" # Critical: Make directory accessible to _apt user
trap 'rm -rf "$TMPDIR"' EXIT
# Get latest version
API_URL="https://api.github.com/repos/juanfont/headscale/releases/latest"
TAG=$(curl -s "$API_URL" | jq -r '.tag_name')
VERSION="${TAG#v}" # Remove 'v' prefix
# Get system architecture
ARCH=$(dpkg --print-architecture)
# Build download URL
DEB_URL="https://github.com/juanfont/headscale/releases/download/${TAG}/headscale_${VERSION}_linux_${ARCH}.deb"
# Download package to temp directory
DEB_FILE="${TMPDIR}/headscale.deb"
echo "Downloading headscale ${VERSION} (${ARCH})..."
curl -L -o "$DEB_FILE" "$DEB_URL"
chmod 644 "$DEB_FILE" # Make .deb file readable by all users
# Install package from temp location
echo "Installing..."
sudo apt install -y "$DEB_FILE"
echo -e "\nInstallation complete!"
sudo systemctl enable headscale
sudo systemctl start headscale
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment