Fails faster on ssh connection

This commit is contained in:
Maniack Crudelis 2018-10-17 15:23:19 +02:00
parent e89e146809
commit e3e1cda79c

View file

@ -171,7 +171,7 @@ LXC_START () {
do do
echo -n . echo -n .
# Try to connect with ssh to check if the container is ready to work. # Try to connect with ssh to check if the container is ready to work.
if ssh $arg_ssh $lxc_name "exit 0" > /dev/null 2>&1; then if ssh $arg_ssh -o ConnectTimeout=10 $lxc_name "exit 0" > /dev/null 2>&1; then
# Break the for loop if the container is ready. # Break the for loop if the container is ready.
break break
fi fi
@ -188,7 +188,7 @@ LXC_START () {
ECHO_FORMAT "Rebooting the container...\n" "red" "bold" ECHO_FORMAT "Rebooting the container...\n" "red" "bold"
fi fi
LXC_STOP # Stop the LXC container LXC_STOP # Stop the LXC container
elif ! ssh $arg_ssh $lxc_name "sudo ping -q -c 2 security.debian.org > /dev/null 2>&1; exit \$?" >> "$test_result" 2>&1 elif ! ssh $arg_ssh -o ConnectTimeout=60 $lxc_name "sudo ping -q -c 2 security.debian.org > /dev/null 2>&1; exit \$?" >> "$test_result" 2>&1
then then
# Try to ping security.debian.org to check the connectivity from the container # Try to ping security.debian.org to check the connectivity from the container
ECHO_FORMAT "The container failed to connect to internet...\n" "red" "bold" ECHO_FORMAT "The container failed to connect to internet...\n" "red" "bold"