um-service-cfg: Small improvements

Since kernel 5.10 upgrade, this script was actually not working
properly. The script is waiting on network.target to be ready, but
network.target does not mean that the route to user module is already
setup. And since with kernel 5.10 the route needs a bridge to be setup,
this takes a bit longer to be ready.

When there is no route to an IP address, ping does not wait the
specified timeout (-W) and returns immediately with an error. this was
leading to the 30 pings being done over a much smaller time period than
expected and therefore made the service fail before the route was setup.

Also in case the user module was not found, the service did not fail but
continued checking the port, which failed (of course) and the script was
then wrongly assuming the presence of an old UM.

BugzID: 81969
This commit is contained in:
Alexandre Bard 2022-11-14 13:48:47 +01:00
parent c4f38ccd97
commit 66216504ee
1 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/usr/bin/env bash
UM_CONFIG_PATH=/etc/user-module UM_CONFIG_PATH=/etc/user-module
UM_CONFIG_FILE=network.conf UM_CONFIG_FILE=network.conf
@ -37,16 +37,22 @@ done
source $UM_CONFIG source $UM_CONFIG
max_retry=30 max_retry=15
counter=0 counter=0
until [[ counter -ge $max_retry ]] until [[ counter -ge $max_retry ]]
do do
echo "Probing um. #$counter" echo "Probing um. #$counter"
ping -qc 1 -W 1 $USER_MODULE_ipv4_addr && break ping -qc 1 -W 1 $USER_MODULE_ipv4_addr && break
sleep 1
((counter++)) ((counter++))
done done
if ! ping -qc 1 -W 1 $USER_MODULE_ipv4_addr
then
echo "UM not reachable"
exit 1
fi
# Decide which config to load depending on the sw revision # Decide which config to load depending on the sw revision
if `nc -z $USER_MODULE_ipv4_addr 7000` ; then if `nc -z $USER_MODULE_ipv4_addr 7000` ; then