Files
public-image-mirror/hack/verify-allows.sh
Shiming Zhang bed1cd3c82 Fix check image
2025-02-08 19:13:50 +08:00

33 lines
709 B
Bash
Executable File

#!/usr/bin/env bash
file=$1
image=$2
function check_allows() {
local file=$1
local image=$2
if [[ "${image}" == *":" ]]; then
return 1
fi
while read line; do
if [[ "${line}" == *"**" ]]; then
if [[ "${image}" == "${line%\*\*}"* ]]; then
return 0
fi
elif [[ "${line}" == *"*" ]]; then
if [[ "${image}" == "${line%\*}"* ]]; then
if [[ "${image#"${line%\*}"}" != *"/"* ]]; then
return 0
fi
fi
elif [[ "${line}" == "${image%\:*}" ]]; then
return 0
fi
done <"${file}"
return 1
}
check_allows "${file}" "${image}"