mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
LXC_STOP to ynh_lxc_stop
This commit is contained in:
parent
0a0ef64ed6
commit
01a6a7572f
3 changed files with 18 additions and 18 deletions
|
@ -347,7 +347,7 @@ TEST_LAUNCHER () {
|
||||||
# End the timer for the test
|
# End the timer for the test
|
||||||
stop_timer 2
|
stop_timer 2
|
||||||
|
|
||||||
LXC_STOP $LXC_NAME
|
ynh_lxc_stop $LXC_NAME
|
||||||
|
|
||||||
# Update the lock file with the date of the last finished test.
|
# Update the lock file with the date of the last finished test.
|
||||||
# $$ is the PID of package_check itself.
|
# $$ is the PID of package_check itself.
|
||||||
|
|
15
lib/ynh_lxd
15
lib/ynh_lxd
|
@ -4,6 +4,19 @@
|
||||||
# LXD HELPERS
|
# LXD HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_lxc_stop () {
|
||||||
|
local container_to_stop=$1
|
||||||
|
# (We also use timeout 30 in front of the command because sometime lxc
|
||||||
|
# commands can hang forever despite the --timeout >_>...)
|
||||||
|
timeout 30 lxc stop --timeout 15 $container_to_stop 2>/dev/null
|
||||||
|
|
||||||
|
# If the command times out, then add the option --force
|
||||||
|
if [ $? -eq 124 ]; then
|
||||||
|
timeout 30 lxc stop --timeout 15 $container_to_stop --force 2>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ynh_lxc_snapshot_exists () {
|
ynh_lxc_snapshot_exists () {
|
||||||
local snapname=$1
|
local snapname=$1
|
||||||
lxc list --format json \
|
lxc list --format json \
|
||||||
|
@ -19,7 +32,7 @@ ynh_lxc_snapshot_load () {
|
||||||
# Remove swap files before restoring the snapshot.
|
# Remove swap files before restoring the snapshot.
|
||||||
CLEAN_SWAPFILES
|
CLEAN_SWAPFILES
|
||||||
|
|
||||||
LXC_STOP $LXC_NAME
|
ynh_lxc_stop $LXC_NAME
|
||||||
|
|
||||||
lxc restore $LXC_NAME $snapname
|
lxc restore $LXC_NAME $snapname
|
||||||
lxc start $LXC_NAME
|
lxc start $LXC_NAME
|
||||||
|
|
|
@ -161,7 +161,7 @@ ynh_lxc_pc_snapshot_create () {
|
||||||
# Remove swap files to avoid killing the CI with huge snapshots.
|
# Remove swap files to avoid killing the CI with huge snapshots.
|
||||||
CLEAN_SWAPFILES
|
CLEAN_SWAPFILES
|
||||||
|
|
||||||
LXC_STOP $LXC_NAME
|
ynh_lxc_stop $LXC_NAME
|
||||||
|
|
||||||
# Check if the snapshot already exist
|
# Check if the snapshot already exist
|
||||||
if ! ynh_lxc_snapshot_exists "$snapname"
|
if ! ynh_lxc_snapshot_exists "$snapname"
|
||||||
|
@ -175,19 +175,6 @@ ynh_lxc_pc_snapshot_create () {
|
||||||
stop_timer 1
|
stop_timer 1
|
||||||
}
|
}
|
||||||
|
|
||||||
LXC_STOP () {
|
|
||||||
local container_to_stop=$1
|
|
||||||
# (We also use timeout 30 in front of the command because sometime lxc
|
|
||||||
# commands can hang forever despite the --timeout >_>...)
|
|
||||||
timeout 30 lxc stop --timeout 15 $container_to_stop 2>/dev/null
|
|
||||||
|
|
||||||
# If the command times out, then add the option --force
|
|
||||||
if [ $? -eq 124 ]; then
|
|
||||||
timeout 30 lxc stop --timeout 15 $container_to_stop --force 2>/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
LXC_RESET () {
|
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
|
||||||
|
@ -195,7 +182,7 @@ LXC_RESET () {
|
||||||
CLEAN_SWAPFILES
|
CLEAN_SWAPFILES
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LXC_STOP $LXC_NAME
|
ynh_lxc_stop $LXC_NAME
|
||||||
|
|
||||||
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
|
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
|
||||||
local current_storage=$(lxc list $LXC_NAME --format json --columns b | jq '.[].expanded_devices.root.pool')
|
local current_storage=$(lxc list $LXC_NAME --format json --columns b | jq '.[].expanded_devices.root.pool')
|
||||||
|
@ -210,7 +197,7 @@ _LXC_START_AND_WAIT() {
|
||||||
|
|
||||||
restart_container()
|
restart_container()
|
||||||
{
|
{
|
||||||
LXC_STOP $1
|
ynh_lxc_stop $1
|
||||||
lxc start "$1"
|
lxc start "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue