mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Improving _ynh_lxc_start_and_wait
This commit is contained in:
parent
f5332971ed
commit
ffa77e8e61
1 changed files with 6 additions and 5 deletions
11
lib/ynh_lxd
11
lib/ynh_lxd
|
@ -211,6 +211,7 @@ _ynh_lxc_start_and_wait () {
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
# Try to start the container 3 times.
|
# Try to start the container 3 times.
|
||||||
|
ynh_lxc_start --name=$name
|
||||||
local max_try=3
|
local max_try=3
|
||||||
local i=0
|
local i=0
|
||||||
while [ $i -lt $max_try ]
|
while [ $i -lt $max_try ]
|
||||||
|
@ -221,7 +222,8 @@ _ynh_lxc_start_and_wait () {
|
||||||
# Wait for container to start, we are using systemd to check this,
|
# Wait for container to start, we are using systemd to check this,
|
||||||
# for the sake of brevity.
|
# for the sake of brevity.
|
||||||
for j in $(seq 1 10); do
|
for j in $(seq 1 10); do
|
||||||
if lxc exec "$name" -- systemctl isolate multi-user.target >/dev/null 2>/dev/null; then
|
if ynh_lxc_run_inside --name=$name --command="systemctl isolate multi-user.target >/dev/null 2>/dev/null"
|
||||||
|
then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -237,7 +239,8 @@ _ynh_lxc_start_and_wait () {
|
||||||
|
|
||||||
# Wait for container to access the internet
|
# Wait for container to access the internet
|
||||||
for j in $(seq 1 10); do
|
for j in $(seq 1 10); do
|
||||||
if lxc exec "$name" -- curl -s http://wikipedia.org > /dev/null 2>/dev/null; then
|
if ynh_lxc_run_inside --name=$name --command="curl -s http://wikipedia.org > /dev/null 2>/dev/null"
|
||||||
|
then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -266,7 +269,7 @@ _ynh_lxc_start_and_wait () {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
LXC_IP=$(lxc exec $name -- hostname -I | cut -d' ' -f1 | grep -E -o "\<[0-9.]{8,}\>")
|
LXC_IP=$(ynh_lxc_run_inside --name=$name --command="hostname -I | cut -d' ' -f1 | grep -E -o \"\<[0-9.]{8,}\>\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
# Launch a new LXC from an image
|
# Launch a new LXC from an image
|
||||||
|
@ -321,7 +324,6 @@ ynh_lxc_swapfiles_clean () {
|
||||||
|
|
||||||
# Restart it if needed
|
# Restart it if needed
|
||||||
if [ "$(lxc info $name | grep Status | awk '{print tolower($2)}')" != "running" ]; then
|
if [ "$(lxc info $name | grep Status | awk '{print tolower($2)}')" != "running" ]; then
|
||||||
ynh_lxc_start --name=$name
|
|
||||||
_ynh_lxc_start_and_wait --name=$name
|
_ynh_lxc_start_and_wait --name=$name
|
||||||
fi
|
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 swapoff $swapfile; done'
|
||||||
|
@ -407,7 +409,6 @@ ynh_lxc_snapshot_load () {
|
||||||
ynh_lxc_stop --name=$name
|
ynh_lxc_stop --name=$name
|
||||||
|
|
||||||
lxc restore $name $snapname
|
lxc restore $name $snapname
|
||||||
ynh_lxc_start --name=$name
|
|
||||||
_ynh_lxc_start_and_wait --name=$name
|
_ynh_lxc_start_and_wait --name=$name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue