Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks
tgrushka opened this issue Mar 26, 2025 · 3 comments
Open
2 tasks

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

tgrushka opened this issue Mar 26, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@tgrushka
Copy link

tgrushka commented Mar 26, 2025

Use case

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

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

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 tgrushka added the enhancement New feature or request label Mar 26, 2025
@tgrushka
Copy link
Author

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"

@kradalby
Copy link
Collaborator

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.

@numfin
Copy link

numfin commented Apr 5, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants