From c0e80820010cc5b0fdea1eb69bafef7f575e3201 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 8 Feb 2026 20:23:31 +0800 Subject: first --- client.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 client.sh (limited to 'client.sh') diff --git a/client.sh b/client.sh new file mode 100755 index 0000000..2118a73 --- /dev/null +++ b/client.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# Install tailscale and register with a headscale server +# Copy to a VM and run: sudo ./client.sh +# Example: sudo ./client.sh 37.27.166.243 hskey-auth-xxxx +# macOS CLI: echo 'alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale"' >> ~/.zshrc +set -e + +die() { echo "Error: $1" >&2; exit 1; } +info() { echo " $1"; } + +[[ $EUID -eq 0 ]] || die "Must run as root" + +SERVER_IP="${1:?Usage: $0 }" +AUTH_KEY="${2:?Usage: $0 }" +LOGIN_SERVER="http://${SERVER_IP}:8080" + +echo "=== Installing Tailscale Client ===" +echo "Server: $LOGIN_SERVER" +echo "" + +# 1. Install tailscale +if command -v tailscale &>/dev/null; then + info "Tailscale already installed: $(tailscale version | head -1)" +else + info "Installing tailscale..." + dnf install -y tailscale +fi + +# 2. Start tailscaled +info "Starting tailscaled..." +systemctl enable --now tailscaled + +# 3. Register with headscale +info "Registering with headscale at $LOGIN_SERVER..." +tailscale up --login-server "$LOGIN_SERVER" --authkey "$AUTH_KEY" + +# 4. Show status +echo "" +echo "=== Connected ===" +tailscale status +echo "" +echo "To disconnect: tailscale down" +echo "To switch server: tailscale down && tailscale up --login-server http://:8080 --authkey --force-reauth" +echo "To remove: tailscale down && systemctl disable --now tailscaled && dnf remove -y tailscale" -- cgit