Fixed Tailscale auth sequence

This commit is contained in:
Brian Zalewski 2024-05-13 03:31:26 +00:00
parent f01f38d145
commit 6b201206dc
2 changed files with 32 additions and 13 deletions

View file

@ -1,8 +1,8 @@
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB4eUNoMlc0VXNQS21zaURI
aFVtVGpsOGRWQTI0ZFc5ZmpEVUNZRSs5VTMwCmswKzcwOExpbVNZTHpXTE9hK1RW
N0dkRVRjZXNIYzhXT2tGcmZVMm1XbkkKLS0tIDFCeWJZR1hPN3BISi8wVUo1TmFa
QmVMNnhDUEtGbHNLL0kvcDRpN2FYK2sKjKuAZ9XM2UmZOj9ieANMi6i40MeHCWQV
aT+tQqnolBmenn0J+VVMSalhnc8/GsIx0kyUV2yM6WvfMWwnlzMUlLk4ULFJy2nl
vkooM7iZIf8DNXjAZ17uEJs=
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBsaGJ1ZG9VWVduVDA4VFA1
empCeDNERmtWeGhVWTQ5QlpSRXpybjZ2MUFNCkV3UzhXQ3BmRjdwc09LaU5XclNq
VnMyUjdBUXYrWERYVmdPSG4wZWk3TWMKLS0tIE0xQXVBWExnSkl0bndtTjg0cC93
TjVadlVqU3U3aEFCcTB2WFN6UnZxSHcKQszLGd6LHfPXSqkIiF4BzCERqF34QOXJ
1vPj7h70g1ay2kjSZ73bw38eLtvne2nzUzEPu0J+XLq30S7j5Tcj9DC3JaetPnnx
25BHfHuTSD++Cj6aq/HA0fsQR9AcWw==
-----END AGE ENCRYPTED FILE-----

View file

@ -15,15 +15,34 @@ if [ -d /Applications ] && [ -d System ]; then
else
logg info 'tailscaled does not appear to be installed'
fi
### Open Tailscale.app
if [ -d /Applications/Tailscale.app ]; then
logg info 'Opening Tailscale.app menu bar widget' && open -a Tailscale
else
logg info '/Applications/Tailscale.app is missing from the system'
fi
fi
### Connect to Tailscale network
if command -v tailscale > /dev/null && [ "$TAILSCALE_AUTH_KEY" != "" ]; then
logg info 'Connecting to Tailscale with user-defined authentication key'
timeout 14 tailscale up --authkey="$TAILSCALE_AUTH_KEY" --accept-routes || EXIT_CODE=$?
if [ -n "$EXIT_CODE" ]; then
logg warn 'tailscale up timed out'
if [ -n "$TAILSCALE_AUTH_KEY" ] && [ "$TAILSCALE_AUTH_KEY" != "" ]; then
if [ -f /Applications/Tailscale.app/Contents/MacOS/Tailscale ]; then
logg info 'Connecting to Tailscale with user-defined authentication key (TAILSCALE_AUTH_KEY)'
timeout 30 /Applications/Tailscale.app/Contents/MacOS/Tailscale up --authkey="$TAILSCALE_AUTH_KEY" --accept-routes || EXIT_CODE=$?
if [ -n "$EXIT_CODE" ]; then
logg warn '/Applications/Tailscale.app/Contents/MacOS/Tailscale timed out'
fi
elif command -v tailscale > /dev/null && [ "$TAILSCALE_AUTH_KEY" != "" ]; then
logg info 'Connecting to Tailscale with user-defined authentication key (TAILSCALE_AUTH_KEY)'
timeout 30 tailscale up --authkey="$TAILSCALE_AUTH_KEY" --accept-routes || EXIT_CODE=$?
if [ -n "$EXIT_CODE" ]; then
logg warn 'tailscale up timed out'
else
logg success 'Connected to Tailscale network'
fi
else
logg success 'Connected to Tailscale network'
logg info 'tailscale does not appear to be installed'
fi
else
logg info 'TAILSCALE_AUTH_KEY is not defined so not logging into Tailscale network'
fi