6 SNAP_CHANNEL
="${2:-stable}"
7 SNAP_INSTALL_LOCATION
="${3:-/snap}"
9 SNAP_METADATA
="$(curl --header 'X-Ubuntu-Series: 16' "https
://api.snapcraft.io
/api
/v
1/snaps
/details
/$SNAP_NAME?channel
=$SNAP_CHANNEL")"
12 SNAP_SHA512
="$(echo "$SNAP_METADATA" | jq '.download_sha512' -r)"
13 SNAP_DOWNLOAD_URL
="$(echo "$SNAP_METADATA" | jq '.download_url' -r)"
14 SNAP_LAST_UPDATED
="$(echo "$SNAP_METADATA" | jq '.last_updated' -r)"
15 SNAP_REVISION
="$(echo "$SNAP_METADATA" | jq '.revision' -r)"
16 SNAP_VERSION
="$(echo "$SNAP_METADATA" | jq '.version' -r)"
19 echo "Downloading $SNAP_NAME, version $SNAP_VERSION, revision $SNAP_REVISION (last updated: $SNAP_LAST_UPDATED)..."
20 curl
--location "$SNAP_DOWNLOAD_URL" --output "$SNAP_NAME.snap"
21 sha512sum
-c <(echo "$SNAP_SHA512 $SNAP_NAME.snap")
23 mkdir
-p "$SNAP_INSTALL_LOCATION/$SNAP_NAME"
24 unsquashfs
-d "$SNAP_INSTALL_LOCATION/$SNAP_NAME/current" "$SNAP_NAME.snap"
27 echo "$SNAP_NAME version $SNAP_VERSION has correctly been uploaded and installed."