2020-07-19 08:16:11 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
|
|
|
|
source .env
|
|
|
|
AUTH_URL="${AUTH_URL:-"http://localhost:3000/api"}"
|
|
|
|
|
|
|
|
# 1. (srv) create a new shared key for a given slug
|
|
|
|
# 2. (dev) try to update via ping
|
|
|
|
# 3. (dev) use key to exchange machine id
|
|
|
|
# 4. (dev) use key to connect to remote
|
|
|
|
# 5. (dev) ping occasionally
|
|
|
|
|
|
|
|
echo "CLIENT_SECRET: $CLIENT_SECRET"
|
2020-07-20 15:27:31 +00:00
|
|
|
TOKEN=$(go run cmd/signjwt/*.go --vendor-id "$VENDOR_ID" --secret "$CLIENT_SECRET")
|
|
|
|
echo "TOKEN 1: '$TOKEN'"
|
2020-07-19 08:16:11 +00:00
|
|
|
|
2020-07-20 15:27:31 +00:00
|
|
|
my_parts=$(go run cmd/signjwt/*.go --vendor-id "$VENDOR_ID" --secret $CLIENT_SECRET --machine-ppid-only)
|
2020-07-19 08:16:11 +00:00
|
|
|
my_ppid=$(echo $my_parts | cut -d' ' -f1)
|
|
|
|
my_keyid=$(echo $my_parts | cut -d' ' -f2)
|
|
|
|
echo "PPID: $my_ppid KeyID: $my_keyid"
|
|
|
|
|
2020-07-20 15:27:31 +00:00
|
|
|
echo "$AUTH_URL"
|
|
|
|
curl -X POST "$AUTH_URL/ping" -H "Authorization: Bearer ${TOKEN}"
|
|
|
|
echo ""
|
2020-07-19 08:16:11 +00:00
|
|
|
curl "$AUTH_URL/inspect" -H "Authorization: Bearer ${TOKEN}"
|
2020-07-20 15:27:31 +00:00
|
|
|
echo ""
|