Allow download-frozen-image.sh to work on user images too
To account for "/" not working in filenames, we replace it with "_" for our temporary files (that exist only to emulate Bash 4's associative arrays in Bash 3). Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
This commit is contained in:
parent
4895a887e2
commit
ca8fa6e46d
1 changed files with 8 additions and 4 deletions
|
@ -42,6 +42,8 @@ while [ $# -gt 0 ]; do
|
||||||
[ "$tag" != "$imageTag" ] || tag='latest'
|
[ "$tag" != "$imageTag" ] || tag='latest'
|
||||||
tag="${tag%@*}"
|
tag="${tag%@*}"
|
||||||
|
|
||||||
|
imageFile="${image//\//_}" # "/" can't be in filenames :)
|
||||||
|
|
||||||
token="$(curl -sSL -o /dev/null -D- -H 'X-Docker-Token: true' "https://index.docker.io/v1/repositories/$image/images" | tr -d '\r' | awk -F ': *' '$1 == "X-Docker-Token" { print $2 }')"
|
token="$(curl -sSL -o /dev/null -D- -H 'X-Docker-Token: true' "https://index.docker.io/v1/repositories/$image/images" | tr -d '\r' | awk -F ': *' '$1 == "X-Docker-Token" { print $2 }')"
|
||||||
|
|
||||||
if [ -z "$imageId" ]; then
|
if [ -z "$imageId" ]; then
|
||||||
|
@ -60,12 +62,12 @@ while [ $# -gt 0 ]; do
|
||||||
ancestry=( ${ancestryJson//[\[\] \"]/} )
|
ancestry=( ${ancestryJson//[\[\] \"]/} )
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
if [ -s "$dir/tags-$image.tmp" ]; then
|
if [ -s "$dir/tags-$imageFile.tmp" ]; then
|
||||||
echo -n ', ' >> "$dir/tags-$image.tmp"
|
echo -n ', ' >> "$dir/tags-$imageFile.tmp"
|
||||||
else
|
else
|
||||||
images=( "${images[@]}" "$image" )
|
images=( "${images[@]}" "$image" )
|
||||||
fi
|
fi
|
||||||
echo -n '"'"$tag"'": "'"$imageId"'"' >> "$dir/tags-$image.tmp"
|
echo -n '"'"$tag"'": "'"$imageId"'"' >> "$dir/tags-$imageFile.tmp"
|
||||||
|
|
||||||
echo "Downloading '$imageTag' (${#ancestry[@]} layers)..."
|
echo "Downloading '$imageTag' (${#ancestry[@]} layers)..."
|
||||||
for imageId in "${ancestry[@]}"; do
|
for imageId in "${ancestry[@]}"; do
|
||||||
|
@ -90,10 +92,12 @@ done
|
||||||
echo -n '{' > "$dir/repositories"
|
echo -n '{' > "$dir/repositories"
|
||||||
firstImage=1
|
firstImage=1
|
||||||
for image in "${images[@]}"; do
|
for image in "${images[@]}"; do
|
||||||
|
imageFile="${image//\//_}" # "/" can't be in filenames :)
|
||||||
|
|
||||||
[ "$firstImage" ] || echo -n ',' >> "$dir/repositories"
|
[ "$firstImage" ] || echo -n ',' >> "$dir/repositories"
|
||||||
firstImage=
|
firstImage=
|
||||||
echo -n $'\n\t' >> "$dir/repositories"
|
echo -n $'\n\t' >> "$dir/repositories"
|
||||||
echo -n '"'"$image"'": { '"$(cat "$dir/tags-$image.tmp")"' }' >> "$dir/repositories"
|
echo -n '"'"$image"'": { '"$(cat "$dir/tags-$imageFile.tmp")"' }' >> "$dir/repositories"
|
||||||
done
|
done
|
||||||
echo -n $'\n}\n' >> "$dir/repositories"
|
echo -n $'\n}\n' >> "$dir/repositories"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue