From b5e48b2e3402dddaf8700baa6da4c4a587bfa08b Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 17 May 2023 20:18:34 +0200 Subject: [PATCH] fix prepare and cleanup scripts --- cleanup.sh | 4 ++-- prepare.sh | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cleanup.sh b/cleanup.sh index 1dbfc16..27b98d6 100755 --- a/cleanup.sh +++ b/cleanup.sh @@ -4,6 +4,6 @@ current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" source $current_dir/prints.sh source $current_dir/variables.sh # Get variables from variables. -info "Stopping container $CONTAINER_ID" +info "Stopping container $CONTAINER_IMAGE" -lxc stop "$CONTAINER_ID" \ No newline at end of file +lxc stop "$CONTAINER_IMAGE" \ No newline at end of file diff --git a/prepare.sh b/prepare.sh index 549d67d..42e2525 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 info "$BASE_IMAGE" &>/dev/null || ! lxc info "$BASE_IMAGE" | grep -q "$SNAPSHOT_NAME" + if ! lxc info "$BASE_IMAGE" &>/dev/null || ! lxc info "$BASE_IMAGE" | grep -q "$CURRENT_VERSION-$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 @@ -21,6 +21,10 @@ start_container () { fi lxc copy "$BASE_IMAGE" "$CONTAINER_IMAGE" fi + # Stop the container if it's running + if [ "$(lxc info $CONTAINER_IMAGE | grep Status | awk '{print tolower($2)}')" == "running" ]; then + lxc stop $CONTAINER_IMAGE + fi info "Debian version: $DEBIAN_VERSION, YunoHost version: $CURRENT_VERSION, Image used: $BASE_IMAGE, Snapshot: $SNAPSHOT_NAME"