diff --git a/share/docker/tailscale_container_hook b/share/docker/tailscale_container_hook index 9036cdfc6..bc20c18a9 100755 --- a/share/docker/tailscale_container_hook +++ b/share/docker/tailscale_container_hook @@ -249,11 +249,16 @@ fi KEY_EXPIRY=$(tailscale status --json | jq -r '.Self.KeyExpiry') if [ "${KEY_EXPIRY}" != "null" ]; then EXPIRY_EPOCH=$(date -d "${KEY_EXPIRY}" +"%s" 2>/dev/null) + if [ -z "${EXPIRY_EPOCH}" ]; then + EXPIRY_EPOCH=$(date -d "$(echo "${KEY_EXPIRY}" | sed 's/T/ /; s/Z//')" +"%s") + fi CUR_EPOCH=$(date -u +%s) DIFF_EPOCH=$((EXPIRY_EPOCH - CUR_EPOCH)) DIFF_DAYS=$((DIFF_EPOCH / 86400)) HOST=$(tailscale status --json | jq -r '.Self.HostName') - if [ -n "${DIFF_DAYS}" ] && echo "${DIFF_DAYS}" | grep -Eq '^[0-9]+$'; then + if [ -z "${EXPIRY_EPOCH}" ]; then + echo "WARNING: An error occurred while retrieving the Tailscale key expiry!" + elif [ -n "${DIFF_DAYS}" ] && echo "${DIFF_DAYS}" | grep -Eq '^[0-9]+$'; then echo "WARNING: Tailscale Key will expire in ${DIFF_DAYS} days." echo " Navigate to https://login.tailscale.com/admin/machines and 'Disable Key Expiry' for ${HOST}" else