fix prepare and cleanup scripts

This commit is contained in:
Kay0u 2023-05-17 20:18:34 +02:00
parent cc0bcaf600
commit b5e48b2e34
No known key found for this signature in database
GPG key ID: AAFEEB16CFA2AE2D
2 changed files with 7 additions and 3 deletions

View file

@ -4,6 +4,6 @@ current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $current_dir/prints.sh source $current_dir/prints.sh
source $current_dir/variables.sh # Get variables from variables. source $current_dir/variables.sh # Get variables from variables.
info "Stopping container $CONTAINER_ID" info "Stopping container $CONTAINER_IMAGE"
lxc stop "$CONTAINER_ID" lxc stop "$CONTAINER_IMAGE"

View file

@ -12,7 +12,7 @@ trap "exit $SYSTEM_FAILURE_EXIT_CODE" ERR
start_container () { start_container () {
if ! lxc info "$CONTAINER_IMAGE" >/dev/null 2>/dev/null ; then if ! lxc info "$CONTAINER_IMAGE" >/dev/null 2>/dev/null ; then
warn 'Container not found, copying it from the prebuilt image' 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 then
error "$BASE_IMAGE not found, please rebuild with rebuild_all.sh" error "$BASE_IMAGE not found, please rebuild with rebuild_all.sh"
# Inform GitLab Runner that this is a system failure, so it # Inform GitLab Runner that this is a system failure, so it
@ -21,6 +21,10 @@ start_container () {
fi fi
lxc copy "$BASE_IMAGE" "$CONTAINER_IMAGE" lxc copy "$BASE_IMAGE" "$CONTAINER_IMAGE"
fi 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" info "Debian version: $DEBIAN_VERSION, YunoHost version: $CURRENT_VERSION, Image used: $BASE_IMAGE, Snapshot: $SNAPSHOT_NAME"