headscale icon indicating copy to clipboard operation
headscale copied to clipboard

[Feature] Better setup / install docs / avoid reinventing the wheel

Open tgrushka opened this issue 9 months ago • 3 comments

Use case

Thanks for this project. Trying to set up / figure it out.

Considering the simplicity of installation of other popular, well-known projects:

  • Rust: https://rustup.rs/
  • Homebrew: https://brew.sh/
  • many others...

Why can't we just have a command-line install like these have?

This manual config of version numbers is really tedious, especially if we each have to re-invent the wheel to do an automated / semi-auto update process, since this is not part of a packaged system.

Here's what DeepSeek just generated for me (no idea if it works yet), but why can't this repo have an official shell script that we just curl and it does this for us? It would save countless hours across thousands of people.

Thank you....

Description

Here's a script that automatically fetches and installs the latest headscale .deb package for your system's architecture:

#!/bin/bash

set -euo pipefail

# 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; }

# 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
echo "Downloading headscale ${VERSION} (${ARCH})..."
curl -L -o headscale.deb "$DEB_URL"

# Install package
echo "Installing..."
sudo apt install -y ./headscale.deb

# Cleanup
rm -f headscale.deb

echo -e "\nInstallation complete!"
echo "Configure headscale: sudo nano /etc/headscale/config.yaml"
echo "Start service: sudo systemctl enable --now headscale"

Features:

  • Automatically detects latest version from GitHub API
  • Uses your system's architecture (amd64/arm64/etc)
  • Uses Debian's package architecture naming convention
  • Handles GitHub's redirects for actual download
  • Clean error checking and dependencies verification

To use:

  • Save as install-headscale.sh
  • chmod +x install-headscale.sh
  • sudo ./install-headscale.sh

The script will:

  • Check for required dependencies (curl + jq)
  • Find the latest release version
  • Determine your system architecture
  • Download the correct package
  • Install using apt
  • Clean up temporary files
  • Show post-install instructions

Note: You may need to install jq first (sudo apt install jq) if you don't have it already.

Contribution

  • [ ] I can write the design doc for this feature
  • [ ] I can contribute this feature

How can it be implemented?

Create a shell script and curl command line that can be run to automate install/upgrade. If it's infeasible to do on multiple distros, at least create the recommended one that will run on Ubuntu/Debian.

tgrushka avatar Mar 26 '25 20:03 tgrushka

And it took two more iterations to get it right and get rid of the sandboxed warning:

(Imagine thousands of users going through the same process that I did and trying to figure it out... Maybe a "first-world problem," but so does this project solve for that matter...)

#!/bin/bash

set -euo pipefail

# 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!"
echo "Configure headscale: sudo nano /etc/headscale/config.yaml"
echo "Check service status: sudo systemctl status headscale"

tgrushka avatar Mar 26 '25 20:03 tgrushka

Thanks, but I generally dont agree with that this would improve this for thousands, I, and I think a lot of other sysadmins has their own setup (ansible, nix, chef, puppet, saltstack) and would in general be very sceptical to those kind of scripts.

In addition, where should you draw the line for distributions, this only works for debian, what about the other distribution or distro independence.

I would also not really be too comfortable making a script people pipe willy nilly into their setup, quite vulnerable for supply chain attacks, my bash knowledge is not great and in general we can forget to maintain it.

kradalby avatar Mar 30 '25 11:03 kradalby

why would you need script for...

  • copying link that you need from releases page
  • wget <that link>
  • apt install ./that.deb

just 3 actions... wtf is this overengineered ai garbage

numfin avatar Apr 05 '25 06:04 numfin

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] avatar Jul 05 '25 02:07 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jul 12 '25 02:07 github-actions[bot]