tailscale.sh aktualisiert

This commit is contained in:
2024-09-25 12:01:44 +02:00
parent f27043c617
commit 55fc8734bc

View File

@@ -4,6 +4,8 @@
#
# For more information see:
# https://github.com/ich777/tailscale-container-script/blob/master/README.md
#
# tailscale.sh version: 2024-09-25
error_handler() {
echo
@@ -65,21 +67,18 @@ if [[ ! -f /usr/bin/tailscale || ! -f /usr/bin/tailscaled ]]; then
echo "Tailscale not found, downloading..."
echo "Please wait..."
TAILSCALE_JSON=$(wget -qO- 'https://pkgs.tailscale.com/stable/?mode=json')
TAILSCALE_VERSION=$(wget -qO- 'https://pkgs.tailscale.com/stable/?mode=json' | jq -r '.TarballsVersion')
if [ -z "${TAILSCALE_JSON}" ]; then
if [ -z "${TAILSCALE_VERSION}" ]; then
echo "ERROR: Can't get Tailscale JSON"
error_handler
fi
TAILSCALE_TARBALL=$(echo "${TAILSCALE_JSON}" | jq -r .Tarballs.amd64)
TAILSCALE_VERSION=$(echo "${TAILSCALE_JSON}" | jq -r .TarballsVersion)
if [ ! -d /tmp/tailscale ]; then
mkdir -p /tmp/tailscale
fi
if wget -q -nc --show-progress --progress=bar:force:noscroll -O /tmp/tailscale/tailscale.tgz "https://pkgs.tailscale.com/stable/${TAILSCALE_TARBALL}" ; then
if wget -q -nc --show-progress --progress=bar:force:noscroll -O /tmp/tailscale/tailscale.tgz "https://pkgs.tailscale.com/stable/tailscale_${TAILSCALE_VERSION}_amd64.tgz" ; then
echo "Download from Tailscale version ${TAILSCALE_VERSION} successful!"
else
echo "ERROR: Download from Tailscale version ${TAILSCALE_VERSION} failed!"
@@ -93,8 +92,42 @@ if [[ ! -f /usr/bin/tailscale || ! -f /usr/bin/tailscaled ]]; then
cp /tmp/tailscale/tailscale_${TAILSCALE_VERSION}_amd64/tailscaled /usr/bin/tailscaled
rm -rf /tmp/tailscale
echo "Done"
echo "Installation Done"
elif [ "${TAILSCALE_UPDATE}" == "true" ]; then
echo "Version Check enabled, please wait..."
CUR_V="$(tailscale version --json | jq -r '.short')"
LAT_V="$(timeout 5 tailscale version --upstream --json | jq -r '.upstream')"
if [ -z "${LAT_V}" ]; then
echo "ERROR: Can't grab latest version from Tailscale, continuing..."
else
if [ "${CUR_V}" == "${LAT_V}" ]; then
echo "Tailscale version ${CUR_V} up-to-date, continuing..."
else
echo "Found new Tailscale version ${LAT_V}, updating, please wait..."
if [ ! -d /tmp/tailscale ]; then
mkdir -p /tmp/tailscale
fi
unset EXIT_STATUS
if wget -q -nc --show-progress --progress=bar:force:noscroll -O /tmp/tailscale/tailscale.tgz "https://pkgs.tailscale.com/stable/tailscale_${LAT_V}_amd64.tgz" ; then
echo "Download from Tailscale version ${LAT_V} successful!"
else
echo "ERROR: Download from Tailscale version ${LAT_V} failed!"
echo " Falling back to installed version ${CUR_V}"
rm -rf /tmp/tailscale
EXIT_STATUS="failed"
fi
if [ "${EXIT_STATUS}" != "failed" ]; then
cd /tmp/tailscale
tar -xf /tmp/tailscale/tailscale.tgz
cp /tmp/tailscale/tailscale_${TAILSCALE_VERSION}_amd64/tailscale /usr/bin/tailscale
cp /tmp/tailscale/tailscale_${TAILSCALE_VERSION}_amd64/tailscaled /usr/bin/tailscaled
rm -rf /tmp/tailscale
echo "Update Done"
fi
fi
fi
else
echo "Tailscale found, continuing..."
fi