Merge pull request #70 from linuxserver/focal-mod-fix
Use jq to parse JSONpull/71/head focal-86a61917-ls40
commit
0cddd014b2
|
@ -6,17 +6,19 @@ if [ -z ${DOCKER_MODS+x} ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for curl
|
# Check for curl
|
||||||
if [ ! -f /usr/bin/curl ]; then
|
if [ ! -f /usr/bin/curl ] || [ ! -f /usr/bin/jq ]; then
|
||||||
echo "[mod-init] Curl was not found on this system for Docker mods installing"
|
echo "[mod-init] Curl/JQ was not found on this system for Docker mods installing"
|
||||||
if [ -f /usr/bin/apt ]; then
|
if [ -f /usr/bin/apt ]; then
|
||||||
## Ubuntu
|
## Ubuntu
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install --no-install-recommends -y \
|
apt-get install --no-install-recommends -y \
|
||||||
curl
|
curl \
|
||||||
|
jq
|
||||||
elif [ -f /sbin/apk ]; then
|
elif [ -f /sbin/apk ]; then
|
||||||
# Alpine
|
# Alpine
|
||||||
apk add --no-cache \
|
apk add --no-cache \
|
||||||
curl
|
curl \
|
||||||
|
jq
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -30,19 +32,14 @@ get_blob_sha () {
|
||||||
--location \
|
--location \
|
||||||
--request GET \
|
--request GET \
|
||||||
--header "Authorization: Bearer $2" \
|
--header "Authorization: Bearer $2" \
|
||||||
$3 |\
|
$3 | jq -r '.layers[0].digest'
|
||||||
grep -A4 'layers' |\
|
|
||||||
grep -m1 'digest' |\
|
|
||||||
awk -F'"' '{print $4}'
|
|
||||||
else
|
else
|
||||||
curl \
|
curl \
|
||||||
--silent \
|
--silent \
|
||||||
--location \
|
--location \
|
||||||
--request GET \
|
--request GET \
|
||||||
--header "Authorization: Bearer $2" \
|
--header "Authorization: Bearer $2" \
|
||||||
$3 |\
|
$3 | jq -r '.fsLayers[0].blobSum'
|
||||||
grep -m1 "blobSum" |\
|
|
||||||
awk -F'"' '{print $4}'
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +98,7 @@ for DOCKER_MOD in "${DOCKER_MODS[@]}"; do
|
||||||
--silent \
|
--silent \
|
||||||
--header 'GET' \
|
--header 'GET' \
|
||||||
"${AUTH_URL}" \
|
"${AUTH_URL}" \
|
||||||
| awk -F'"' '{print $4}' \
|
| jq -r '.token' \
|
||||||
)"
|
)"
|
||||||
# Determine first and only layer of image
|
# Determine first and only layer of image
|
||||||
SHALAYER=$(get_blob_sha "${MODE}" "${TOKEN}" "${MANIFEST_URL}")
|
SHALAYER=$(get_blob_sha "${MODE}" "${TOKEN}" "${MANIFEST_URL}")
|
||||||
|
|
Ładowanie…
Reference in New Issue