Created
June 29, 2025 09:46
-
-
Save fstanis/fa8db25757ce56fe9c3f49106cb8db3d to your computer and use it in GitHub Desktop.
A script to start, stop or install the Tailscale daemon without root.
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 | |
# A script to start, stop or install the Tailscale daemon without root. | |
# | |
# Usage: | |
# ./tailscale_manager.sh start | |
# ./tailscale_manager.sh stop | |
# ./tailscale_manager.sh install | |
readonly TAILSCALE_URL='https://pkgs.tailscale.com/stable/tailscale_1.84.0_amd64.tgz' | |
readonly TAILSCALE_DIR="$HOME/tailscale" | |
if ! [[ -d "$TAILSCALE_DIR" || "$1" == "install" ]]; then | |
echo "Tailscale installation not found." | |
exit 1 | |
fi | |
readonly SOCKET="$TAILSCALE_DIR/tailscaled.sock" | |
readonly STATE_DIR="$TAILSCALE_DIR/state" | |
readonly TAILSCALED_EXEC="$TAILSCALE_DIR/tailscaled" | |
readonly TAILSCALE_EXEC="$TAILSCALE_DIR/tailscale" | |
mkdir -p "$STATE_DIR" | |
case "$1" in | |
start) | |
echo "Starting Tailscale..." | |
start-stop-daemon \ | |
--start \ | |
--background \ | |
--exec "$TAILSCALED_EXEC" \ | |
-- \ | |
-no-logs-no-support \ | |
-tun "userspace-networking" \ | |
-socket "$SOCKET" \ | |
-statedir "$STATE_DIR" | |
sleep 2 | |
"$TAILSCALE_EXEC" --socket "$SOCKET" up | |
echo "Tailscale started." | |
;; | |
stop) | |
echo "Stopping Tailscale..." | |
"$TAILSCALE_EXEC" --socket "$SOCKET" down | |
start-stop-daemon \ | |
--stop \ | |
--exec "$TAILSCALED_EXEC" | |
echo "Tailscale stopped." | |
;; | |
install) | |
echo "Installing Tailscale..." | |
mkdir -p "$TAILSCALE_DIR" | |
cd "$TAILSCALE_DIR" | |
curl -L "$TAILSCALE_URL" | tar xzf - --strip-components 1 | |
echo "Tailscale installed." | |
;; | |
*) | |
echo "Usage: $0 {start|stop|install}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment