remove swap only if the container exists

This commit is contained in:
Kay0u 2022-08-10 18:51:37 +02:00
parent 98c00ed402
commit 236546ca51
No known key found for this signature in database
GPG key ID: AAFEEB16CFA2AE2D

View file

@ -131,8 +131,10 @@ LXC_RESET () {
LXC_STOP $LXC_NAME LXC_STOP $LXC_NAME
local current_storage=$(lxc list $LXC_NAME --format json --columns b | jq '.[].expanded_devices.root.pool') if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
swapoff "$(lxc storage get $current_storage source)/containers/$LXC_NAME/rootfs/swap" 2>/dev/null local current_storage=$(lxc list $LXC_NAME --format json --columns b | jq '.[].expanded_devices.root.pool')
swapoff "$(lxc storage get $current_storage source)/containers/$LXC_NAME/rootfs/swap" 2>/dev/null
fi
lxc delete $LXC_NAME --force 2>/dev/null lxc delete $LXC_NAME --force 2>/dev/null
} }