Improving ynh_lxc_swapfiles_clean

This commit is contained in:
yalh76 2022-10-24 01:58:26 +02:00
parent 7af7f02a74
commit 8f91c6e28c

View file

@ -344,12 +344,10 @@ ynh_lxc_swapfiles_clean () {
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# Restart it if needed
if [ "$(lxc info $name | grep Status | awk '{print tolower($2)}')" != "running" ]; then
_ynh_lxc_start_and_wait --name=$name
fi
lxc exec $name -- bash -c 'for swapfile in $(ls /swap_* 2>/dev/null); do swapoff $swapfile; done'
lxc exec $name -- bash -c 'for swapfile in $(ls /swap_* 2>/dev/null); do rm -f $swapfile; done'
_ynh_lxc_start_and_wait --name=$name
ynh_lxc_run_inside --name=$name --command='for swapfile in $(ls /swap_* 2>/dev/null); do swapoff $swapfile; done'
ynh_lxc_run_inside --name=$name --command='for swapfile in $(ls /swap_* 2>/dev/null); do rm -f $swapfile; done'
}
# Check if a snapshot exist for an LXC container