pathScripts/ts-new-node-minimalist

24 lines
703 B
Bash
Executable file

#!/bin/bash
# Define the path to your Tailscale binary
tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale"
# Check if Tailscale is running
if ! pgrep "Tailscale" > /dev/null; then
echo "Tailscale is not running. Starting Tailscale..."
open -a "/Applications/Tailscale.app"
# Wait for Tailscale to initialize
sleep 5
$tailscale up
fi
# Select a new exit node from the whitelist and set it
selected_exit_node=$($tailscale exit-node list | grep -f ~/.vpnwhitelist | awk '{print $2}' | shuf -n 1)
if [ -n "$selected_exit_node" ]; then
# Set the new exit node
$tailscale set --exit-node=$selected_exit_node
else
echo "No valid exit node found."
exit 1
fi