Tailscale 1.40.0
Alter machine deletion logic to check tailscale version.
This commit is contained in:
Frank Edwards 2023-05-01 15:10:42 +10:00
parent 36ac5fd76e
commit f7eb620e9c
2 changed files with 15 additions and 18 deletions

View file

@ -25,8 +25,8 @@
# https://mikrotik.com/products/matrix # https://mikrotik.com/products/matrix
# #
PLATFORM="linux/arm/v7" PLATFORM="linux/arm/v7"
TAILSCALE_VERSION=1.38.1 TAILSCALE_VERSION=1.40.0
VERSION=0.1.15 VERSION=0.1.16
set -eu set -eu

View file

@ -7,7 +7,7 @@ echo 'net.ipv4.ip_forward = 1' | tee -a /etc/sysctl.conf
echo 'net.ipv6.conf.all.forwarding = 1' | tee -a /etc/sysctl.conf echo 'net.ipv6.conf.all.forwarding = 1' | tee -a /etc/sysctl.conf
sysctl -p /etc/sysctl.conf sysctl -p /etc/sysctl.conf
# Prepare run dir # Prepare run dirs
if [ ! -d "/var/run/sshd" ]; then if [ ! -d "/var/run/sshd" ]; then
mkdir -p /var/run/sshd mkdir -p /var/run/sshd
fi fi
@ -21,22 +21,19 @@ for s in "${SUBNETS[@]}"; do
ip route add "$s" via "${CONTAINER_GATEWAY}" ip route add "$s" via "${CONTAINER_GATEWAY}"
done done
# Check if this is first-time container startup # Check if the machine exists
if [ ! -f "/var/run/tailscale.sh.pid" ]; then ID=$(curl -sSL "https://api.tailscale.com/api/v2/domain/${DOMAIN}/devices" -u "${API_KEY}:" | jq -r '.[][] | select(.hostname == "'${HOSTNAME}'") | .id' || echo "")
# Delete all the old devices with this hostname. if [[ ! -z "$ID" ]]; then
IDS=$(curl -sSL "https://api.tailscale.com/api/v2/domain/${DOMAIN}/devices" -u "${API_KEY}:" | jq -r '.[][] | select(.hostname == "'${HOSTNAME}'") | .id' || echo "") # Check if this is a differing version. If so, remove the machine
while IFS= read -r id; do VERSION=$(tailscale version | head -n 1)
if [[ ! -z "$id" ]]; then CLIENT_VERSION=$(curl -sSL -XGET -u "${API_KEY}:" "https://api.tailscale.com/api/v2/device/$ID" | jq -r '.clientVersion' || echo "")
echo "deleting tailscale device: $id"; if [[ "$CLIENT_VERSION" != "$VERSION"* ]]; then
curl -sSL -XDELETE -u "${API_KEY}:" "https://api.tailscale.com/api/v2/device/$id"; # Delete the machine
echo "Deleting tailscale machine: $ID";
curl -sSL -XDELETE -u "${API_KEY}:" "https://api.tailscale.com/api/v2/device/$ID";
fi fi
done <<EOL
$IDS
EOL
fi fi
echo $$ >/var/run/tailscale.sh.pid
# Start tailscaled and bring tailscale up # Start tailscaled and bring tailscale up
/usr/local/bin/tailscaled & /usr/local/bin/tailscaled &
until /usr/local/bin/tailscale up \ until /usr/local/bin/tailscale up \