mirror of
https://github.com/linuxserver/docker-mods.git
synced 2026-01-20 20:33:57 +08:00
Properly support all SHA manifest formats
This commit is contained in:
parent
ed2093ab36
commit
8d069dbd46
@ -295,29 +295,43 @@ run_mods() {
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
ENDPOINT="${DOCKER_MOD%%:*}"
|
||||
USERNAME="${DOCKER_MOD%%/*}"
|
||||
REPO="${ENDPOINT#*/}"
|
||||
FULLTAG="${DOCKER_MOD#*:}"
|
||||
TAG="${FULLTAG%@*}"
|
||||
TAGSHA="${DOCKER_MOD#*@}"
|
||||
if [[ ! "${TAGSHA}" =~ sha256: ]]; then
|
||||
# Identify what kind of image name format we're working with
|
||||
if [[ ${DOCKER_MOD} == *:*@* ]]; then
|
||||
ENDPOINT="${DOCKER_MOD%%:*}"
|
||||
USERNAME="${DOCKER_MOD%%/*}"
|
||||
REPO="${ENDPOINT#*/}"
|
||||
FULLTAG="${DOCKER_MOD#*:}"
|
||||
TAG="${FULLTAG%@*}"
|
||||
TAGSHA="${DOCKER_MOD#*@}"
|
||||
elif [[ ${DOCKER_MOD} == *@* ]]; then
|
||||
ENDPOINT="${DOCKER_MOD%%@*}"
|
||||
USERNAME="${DOCKER_MOD%%/*}"
|
||||
REPO="${ENDPOINT#*/}"
|
||||
unset FULLTAG
|
||||
unset TAG
|
||||
TAGSHA="${DOCKER_MOD#*@}"
|
||||
elif [[ ${DOCKER_MOD} == *:* ]]; then
|
||||
ENDPOINT="${DOCKER_MOD%%:*}"
|
||||
USERNAME="${DOCKER_MOD%%/*}"
|
||||
REPO="${ENDPOINT#*/}"
|
||||
unset FULLTAG
|
||||
TAG="${DOCKER_MOD#*:}"
|
||||
unset TAGSHA
|
||||
fi
|
||||
if [[ "${TAG}" == "${DOCKER_MOD}" ]]; then
|
||||
TAG="latest"
|
||||
fi
|
||||
FILENAME="${USERNAME}.${REPO}.${TAG}${TAGSHA:+.${TAGSHA#*:}}"
|
||||
FILENAME="${USERNAME}.${REPO}${TAG:+.${TAG}}${TAGSHA:+.${TAGSHA#*:}}"
|
||||
MANIFEST_URL="https://${REGISTRY}/v2/${ENDPOINT}/manifests"
|
||||
BLOB_URL="https://${REGISTRY}/v2/${ENDPOINT}/blobs/"
|
||||
MOD_UA="Mozilla/5.0 (Linux $(uname -m)) linuxserver.io ${REGISTRY}/${ENDPOINT}:${TAG}${TAGSHA:+@$TAGSHA}"
|
||||
write_mod_debug "Registry='${REGISTRY}', Repository='${USERNAME}', Image='${ENDPOINT}', Tag='${TAG}', TagSHA='${TAGSHA:-N/A}'"
|
||||
MOD_UA="Mozilla/5.0 (Linux $(uname -m)) linuxserver.io ${REGISTRY}/${ENDPOINT}${TAG:+:${TAG}}${TAGSHA:+@${TAGSHA}}"
|
||||
write_mod_debug "Registry='${REGISTRY}', Repository='${USERNAME}', Image='${ENDPOINT}', Tag='${TAG:-N/A}', TagSHA='${TAGSHA:-N/A}'"
|
||||
case "${REGISTRY}" in
|
||||
"lscr.io") AUTH_URL="https://ghcr.io/token?scope=repository%3A${USERNAME}%2F${REPO}%3Apull";;
|
||||
"ghcr.io") AUTH_URL="https://ghcr.io/token?scope=repository%3A${USERNAME}%2F${REPO}%3Apull";;
|
||||
"quay.io") AUTH_URL="https://quay.io/v2/auth?service=quay.io&scope=repository%3A${USERNAME}%2F${REPO}%3Apull";;
|
||||
"registry-1.docker.io") AUTH_URL="https://auth.docker.io/token?service=registry.docker.io&scope=repository:${ENDPOINT}:pull";;
|
||||
*) AUTH_URL=$(get_auth_url "${MANIFEST_URL}" "${TAG}")
|
||||
*) AUTH_URL=$(get_auth_url "${MANIFEST_URL}" "${TAG:-${TAGSHA}}")
|
||||
esac
|
||||
# Kill off modification logic if any of the usernames are banned
|
||||
for BANNED in $(curl -s https://raw.githubusercontent.com/linuxserver/docker-mods/master/blacklist.txt); do
|
||||
@ -344,7 +358,7 @@ run_mods() {
|
||||
write_mod_info "Adding ${DOCKER_MOD} to container"
|
||||
# If we're using lscr try and get the manifest from ghcr, if it fails re-request a token from Docker Hub
|
||||
if [[ "${REGISTRY}" == "lscr.io" ]]; then
|
||||
if [[ -n $(curl --user-agent "${MOD_UA}" -sLH "Authorization: Bearer ${TOKEN}" "${MANIFEST_URL}/${TAG}" | jq -r '.errors' >/dev/null 2>&1) ]]; then
|
||||
if [[ -n $(curl --user-agent "${MOD_UA}" -sLH "Authorization: Bearer ${TOKEN}" "${MANIFEST_URL}/${TAG:-${TAGSHA}}" | jq -r '.errors' >/dev/null 2>&1) ]]; then
|
||||
write_mod_debug "Couldn't fetch manifest from ghcr.io, trying docker.io"
|
||||
AUTH_URL="https://auth.docker.io/token?service=registry.docker.io&scope=repository:${ENDPOINT}:pull"
|
||||
TOKEN="$(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user