Skip to content

Commit

Permalink
Make token file relative to the script location
Browse files Browse the repository at this point in the history
  • Loading branch information
pschmitt committed Jan 13, 2024
1 parent 05f0abd commit 1f4cf2b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion zerotier-hosts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@ usage() {
echo " -t, --token API token to use (default: read from $PWD/token)"
}

zt_token() {
if [[ -n "$ZEROTIER_API_TOKEN" ]]
then
echo "$ZEROTIER_API_TOKEN"
return 0
fi

cat "$(cd "$(dirname "$0")" >/dev/null 2>&1; pwd -P)/token" || return 1
}

zt_api() {
local api_host=${ZEROTIER_API_ENDPOINT:-https://api.zerotier.com/api/v1}
local token=${ZEROTIER_API_TOKEN:-$(head -1 "$PWD/token")}
local token
token="$(zt_token)"

if [[ -z "$token" ]]
then
Expand Down

0 comments on commit 1f4cf2b

Please sign in to comment.