-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prepare-device: implement reference prepare-device hook
Fixes: #110 Signed-off-by: Tony Espy <[email protected]>
- Loading branch information
1 parent
e76c575
commit eea8bea
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
|
||
# This file is included for reference purposes. If MODEL_APIKEY is not set | ||
# in snapcraft.yaml (as is the default), it is a no-op. For more about how | ||
# to use this script to connect a device to an IoT App Store, see | ||
# - https://ubuntu.com/core/services/guide/serial-vault-overview | ||
# - https://ubuntu.com/core/services/guide/connecting-devices | ||
# - https://snapcraft.io/docs/gadget-snap#heading--prepare | ||
|
||
set -eu | ||
|
||
if [ -z "$MODEL_APIKEY" ] ; then | ||
exit 0 | ||
fi | ||
|
||
exec >> $SNAP_COMMON/prepare-device-hook.log 2>&1 | ||
|
||
# If you are forking and building your own gadget: | ||
# implement your preferred way of generating a serial number for this device here | ||
snapctl set registration.proposed-serial="\"$(date -u)\"" | ||
|
||
snapctl set device-service.url="https://serial-vault-partners.canonical.com/v1/" | ||
snapctl set device-service.headers="{\"api-key\": \"$MODEL_APIKEY\"}" |