diff --git a/examples/mgmt-add-device.sh b/examples/mgmt-add-device.sh index 7882da1..76fd420 100644 --- a/examples/mgmt-add-device.sh +++ b/examples/mgmt-add-device.sh @@ -1,3 +1,7 @@ +#!/bin/bash +set -e +set -u + source .env # 1. (srv) create a new shared key for a given slug @@ -6,12 +10,14 @@ source .env # 4. (dev) use key to connect to remote # 5. (dev) ping occasionally -TOKEN=$(go run cmd/signjwt/*.go \ - --expires-in 1m \ - --vendor-id "$VENDOR_ID" \ - --secret "$RELAY_SECRET" \ - --machine-ppid "$RELAY_SECRET" -) +TOKEN="$( + go run cmd/signjwt/*.go \ + --expires-in 1m \ + --vendor-id "$VENDOR_ID" \ + --secret "$RELAY_SECRET" \ + --machine-ppid "$RELAY_SECRET" +)" +echo "${TOKEN}" MGMT_URL=${MGMT_URL:-"http://mgmt.example.com:6468/api"} @@ -19,4 +25,4 @@ CLIENT_SUBJECT=${CLIENT_SUBJECT:-"newbie"} curl -X POST "$MGMT_URL/devices" \ -H "Authorization: Bearer ${TOKEN}" \ -H "Content-Type: application/json" \ - -d '{ "slug": "'$CLIENT_SUBJECT'" }' + -d '{ "slug": "'"$CLIENT_SUBJECT"'" }'