From 9c23d090fb41f92b8180ff466681d3541fdcce3a Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 16 May 2023 17:31:19 +0200 Subject: [PATCH] fix update container --- auto_upgrade_container.sh | 4 ++-- prepare.sh | 2 +- rebuild_all.sh | 2 +- utils.sh | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/auto_upgrade_container.sh b/auto_upgrade_container.sh index 9ee92ee..da76b9c 100755 --- a/auto_upgrade_container.sh +++ b/auto_upgrade_container.sh @@ -9,7 +9,7 @@ do do for snapshot in "before-install" "after-install" do - update_image $debian_version $ynh_version $snapshot + update_container $debian_version $ynh_version $snapshot done done done @@ -20,7 +20,7 @@ do do for snapshot in "before-install" "after-install" do - update_image $debian_version $ynh_version $snapshot + update_container $debian_version $ynh_version $snapshot done done done diff --git a/prepare.sh b/prepare.sh index d635a0c..1cb5017 100755 --- a/prepare.sh +++ b/prepare.sh @@ -12,7 +12,7 @@ trap "exit $SYSTEM_FAILURE_EXIT_CODE" ERR start_container () { if ! lxc info "$CONTAINER_IMAGE" >/dev/null 2>/dev/null ; then warn 'Container not found, copying it from the prebuilt image' - if ! lxc image info "$BASE_IMAGE" &>/dev/null + if ! lxc info "$BASE_IMAGE" &>/dev/null || ! lxc info "$BASE_IMAGE" | grep -q "$SNAPSHOT_NAME" then error "$BASE_IMAGE not found, please rebuild with rebuild_all.sh" # Inform GitLab Runner that this is a system failure, so it diff --git a/rebuild_all.sh b/rebuild_all.sh index b222bf7..93c399f 100755 --- a/rebuild_all.sh +++ b/rebuild_all.sh @@ -30,7 +30,7 @@ do lxc delete -f "yunohost-$debian_version-$ynh_version-$snapshot-tmp" - update_image $debian_version $ynh_version $snapshot + update_container $debian_version $ynh_version $snapshot done done done diff --git a/utils.sh b/utils.sh index d325bcd..490d250 100755 --- a/utils.sh +++ b/utils.sh @@ -190,20 +190,20 @@ rebuild_base_containers() lxc stop "$base_image_to_rebuild" } -update_image() { +update_container() { local debian_version=$1 local ynh_version=$2 local snapshot=$3 local image_to_update="yunohost-$debian_version-$ynh_version-$snapshot" - if ! lxc image info "$image_to_update" &>/dev/null + if ! lxc info "$image_to_update" &>/dev/null then error "Unable to upgrade image $image_to_update" return fi # Start and run upgrade - lxc launch "$image_to_update" "$image_to_update" -c security.nesting=true + lxc restore "$image_to_update" "$snapshot" wait_container "$image_to_update"