mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
CLEAN_SWAPFILES to ynh_lxc_swapfiles_clean
This commit is contained in:
parent
17a2403c9d
commit
52e814db28
2 changed files with 13 additions and 13 deletions
14
lib/ynh_lxd
14
lib/ynh_lxd
|
@ -85,6 +85,16 @@ _ynh_lxc_start_and_wait () {
|
||||||
LXC_IP=$(lxc exec $1 -- hostname -I | cut -d' ' -f1 | grep -E -o "\<[0-9.]{8,}\>")
|
LXC_IP=$(lxc exec $1 -- hostname -I | cut -d' ' -f1 | grep -E -o "\<[0-9.]{8,}\>")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ynh_lxc_swapfiles_clean () {
|
||||||
|
# Restart it if needed
|
||||||
|
if [ "$(lxc info $LXC_NAME | grep Status | awk '{print tolower($2)}')" != "running" ]; then
|
||||||
|
lxc start $LXC_NAME
|
||||||
|
_ynh_lxc_start_and_wait $LXC_NAME
|
||||||
|
fi
|
||||||
|
lxc exec $LXC_NAME -- bash -c 'for swapfile in $(ls /swap_* 2>/dev/null); do swapoff $swapfile; done'
|
||||||
|
lxc exec $LXC_NAME -- bash -c 'for swapfile in $(ls /swap_* 2>/dev/null); do rm -f $swapfile; done'
|
||||||
|
}
|
||||||
|
|
||||||
ynh_lxc_snapshot_exists () {
|
ynh_lxc_snapshot_exists () {
|
||||||
local snapname=$1
|
local snapname=$1
|
||||||
lxc list --format json \
|
lxc list --format json \
|
||||||
|
@ -98,7 +108,7 @@ ynh_lxc_snapshot_load () {
|
||||||
log_debug "Loading snapshot $snapname ..."
|
log_debug "Loading snapshot $snapname ..."
|
||||||
|
|
||||||
# Remove swap files before restoring the snapshot.
|
# Remove swap files before restoring the snapshot.
|
||||||
CLEAN_SWAPFILES
|
ynh_lxc_swapfiles_clean
|
||||||
|
|
||||||
ynh_lxc_stop $LXC_NAME
|
ynh_lxc_stop $LXC_NAME
|
||||||
|
|
||||||
|
@ -111,7 +121,7 @@ ynh_lxc_reset () {
|
||||||
# If the container exists
|
# If the container exists
|
||||||
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
|
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
|
||||||
# Remove swap files before deletting the continer
|
# Remove swap files before deletting the continer
|
||||||
CLEAN_SWAPFILES
|
ynh_lxc_swapfiles_clean
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_lxc_stop $LXC_NAME
|
ynh_lxc_stop $LXC_NAME
|
||||||
|
|
|
@ -159,7 +159,7 @@ ynh_lxc_pc_snapshot_create () {
|
||||||
ynh_lxc_pc_witness_files_check >&2
|
ynh_lxc_pc_witness_files_check >&2
|
||||||
|
|
||||||
# Remove swap files to avoid killing the CI with huge snapshots.
|
# Remove swap files to avoid killing the CI with huge snapshots.
|
||||||
CLEAN_SWAPFILES
|
ynh_lxc_swapfiles_clean
|
||||||
|
|
||||||
ynh_lxc_stop $LXC_NAME
|
ynh_lxc_stop $LXC_NAME
|
||||||
|
|
||||||
|
@ -175,16 +175,6 @@ ynh_lxc_pc_snapshot_create () {
|
||||||
stop_timer 1
|
stop_timer 1
|
||||||
}
|
}
|
||||||
|
|
||||||
CLEAN_SWAPFILES() {
|
|
||||||
# Restart it if needed
|
|
||||||
if [ "$(lxc info $LXC_NAME | grep Status | awk '{print tolower($2)}')" != "running" ]; then
|
|
||||||
lxc start $LXC_NAME
|
|
||||||
_ynh_lxc_start_and_wait $LXC_NAME
|
|
||||||
fi
|
|
||||||
lxc exec $LXC_NAME -- bash -c 'for swapfile in $(ls /swap_* 2>/dev/null); do swapoff $swapfile; done'
|
|
||||||
lxc exec $LXC_NAME -- bash -c 'for swapfile in $(ls /swap_* 2>/dev/null); do rm -f $swapfile; done'
|
|
||||||
}
|
|
||||||
|
|
||||||
RUN_INSIDE_LXC() {
|
RUN_INSIDE_LXC() {
|
||||||
lxc exec $LXC_NAME -- "$@"
|
lxc exec $LXC_NAME -- "$@"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue