Tailscale
Копируем и устанавливаем пакет на удаленые сервера, если tailscale блочит русские IP
Решение
Пишем скрипт, который смотрит нашу версию tailscale, загружает пакет (DEB) и устанавливает на удаленную машину (если мы за VPN). Запускаем: REMOTE_SERVER=root@proxmox ./install_tailscale_remote.sh
#!/bin/bash
# Ensure REMOTE_SERVER is provided
if [ -z "$REMOTE_SERVER" ]; then
echo "REMOTE_SERVER is not set. Usage: REMOTE_SERVER=user@remote_server $0"
exit 1
fi
# Get the architecture of the remote server
REMOTE_ARCH=$(ssh $REMOTE_SERVER "uname -m")
# Map the architecture from uname -m to Tailscale's naming convention
case "$REMOTE_ARCH" in
x86_64)
ARCH="amd64"
;;
aarch64)
ARCH="arm64"
;;
armv7l)
ARCH="armhf"
;;
*)
echo "Unsupported architecture: $REMOTE_ARCH. Exiting."
exit 1
;;
esac
# Get the installed version of Tailscale
VERSION=$(dpkg -l | grep -E '^ii\s+tailscale\s+' | awk '{print $3}')
# Check if VERSION was successfully retrieved
if [ -z "$VERSION" ]; then
echo "Failed to find Tailscale version. Make sure Tailscale is installed."
exit 1
fi
# Construct the download URL
URL="https://dl.tailscale.com/stable/tailscale_${VERSION}_${ARCH}.deb"
# Extract the filename from URL
FILENAME=$(basename $URL)
# Download the package to /tmp/
wget -nc $URL -P /tmp/ || { echo "Failed to download $URL"; exit 1; }
# Check if the file exists on the remote server
if ssh $REMOTE_SERVER "test -f /tmp/$FILENAME"; then
echo "File $FILENAME already exists on $REMOTE_SERVER. Skipping copy."
else
# Copy the package to the remote server
scp /tmp/$FILENAME $REMOTE_SERVER:/tmp || { echo "Failed to copy $FILENAME to $REMOTE_SERVER"; exit 1; }
# Install the package on the remote server
ssh $REMOTE_SERVER "dpkg -i /tmp/$FILENAME" || { echo "Failed to install $FILENAME on $REMOTE_SERVER"; exit 1; }
fi