Skip to content

Commit

Permalink
improve container load/install
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulh committed Dec 15, 2023
1 parent e66d1d0 commit 45948b5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
27 changes: 24 additions & 3 deletions scripts/calaos_install
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,30 @@ arch-chroot ${dst} update-initramfs -u

info "--> Exporting container images"
for file in /usr/share/calaos/*.source; do
container_name=$(basename "$file" .source)
source "$file"
podman_export "$container_name" "$IMAGE_SRC" "${dst}"
container_name=$(basename "$file" .source)
source "$file"

if podman images | grep "$IMAGE_SRC"
then
podman_export "$container_name" "$IMAGE_SRC" "${dst}"
else
if [ -e "/var/lib/cache/containers/${container_name}.tar" ]
then
info "Image $IMAGE_SRC not found in local repository, copying it from cache"
rsync -avh /var/lib/cache/containers/${container_name}.tar ${dst}/var/lib/cache/containers/
else
info "Image $IMAGE_SRC not found in local repository, trying to pull it..."

podman pull "$IMAGE_SRC"

if podman images | grep "$IMAGE_SRC"
then
podman_export "$container_name" "$IMAGE_SRC" "${dst}"
else
err "Image $IMAGE_SRC not found, skipping"
fi
fi
fi
done

#Initialize Snapper. Unmount our predefined .snapshot folder, let snapper recreate it (it fails otherwise)
Expand Down
16 changes: 11 additions & 5 deletions scripts/load_containers_cache
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ then

# Podman loads file archive from cache and copy it in the local repository
podman load < "$cache"

echo "Image : $image"

# Remove the cache
rm -rf "$cache"

#check if image is in local repository
if podman images | grep "$image"
then
echo "Image $image loaded"
# Remove the cache
rm -rf "$cache"
else
echo "Error: image $image not loaded, an error occured."
exit 1
fi
fi

0 comments on commit 45948b5

Please sign in to comment.