Created
May 17, 2023 06:50
-
-
Save sarkrui/152c451b386705aa61c8de1c85389b4b to your computer and use it in GitHub Desktop.
Update headscale to the latest for Linux AMD64
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/bash | |
# Set the destination directory | |
DEST_DIR="/usr/local/bin" | |
# Get the latest release tag from the GitHub API | |
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/juanfont/headscale/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') | |
# Form the URL of the latest release binary for Linux AMD64 | |
ASSET_URL="https://github.com/juanfont/headscale/releases/download/${LATEST_RELEASE}/headscale_${LATEST_RELEASE#v}_linux_amd64" | |
# Download the latest release | |
curl -L -o /tmp/headscale $ASSET_URL | |
# Stop headscale service | |
echo "Stopping headscale service..." | |
if ! systemctl stop headscale; then | |
echo "Failed to restart headscale service." | |
fi | |
# Move the binary to the destination directory | |
mv /tmp/headscale $DEST_DIR | |
# Ensure it's executable | |
chmod +x $DEST_DIR/headscale | |
# Restart headscale service | |
echo "Restarting headscale service..." | |
if ! systemctl restart headscale; then | |
echo "Failed to restart headscale service." | |
fi | |
# Print the version of the updated headscale | |
$DEST_DIR/headscale version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment