Skip to content

Commit

Permalink
Do not start mesh in case halow init has not finished
Browse files Browse the repository at this point in the history
Jira-ID: WC-247
entrypoint_nats waits for init_halow process to finish
before generating bridge ip and continuing to start mesh.

Signed-off-by: Saku Auvinen <[email protected]>
  • Loading branch information
saauvine committed Oct 18, 2023
1 parent 89385fc commit 8f75053
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion common/scripts/mesh-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ __get_cpu_serial_number() {
# this function generates the identity id from the mac address and the cpu serial number
generate_identity_id() {
# Split the input into an array of interface names
IFS=' ' read -ra interface_array <<< "wlp1s0 eth0 wlan0 wlan1"
IFS=' ' read -ra interface_array <<< "wlp1s0 wlp2s0 wlp3s0 halow1 eth0 wlan0 wlan1"

mac_address=$(__get_mac_address "${interface_array[@]}")
cpu_serial_number=$(__get_cpu_serial_number)
Expand All @@ -46,6 +46,10 @@ EOF
generate_br_lan_ip() {
local mesh_if_mac
mesh_if_mac="$(ip -brief link | grep "${id0_MESH_VIF}" | awk '{print $3; exit}')"
if [ -z "$mesh_if_mac" ]; then
echo "generate_br_lan_ip: MAC not found for id0_MESH_VIF! Configuration error?" > /dev/kmsg
mesh_if_mac="$(ip -brief link | grep "eth0" | awk '{print $3; exit}')"
fi
local ip_random
ip_random="$(echo "$mesh_if_mac" | cut -b 16-17)"
br_lan_ip="192.168.1."$((16#$ip_random))
Expand Down
5 changes: 5 additions & 0 deletions modules/utils/docker/entrypoint_nats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ else
generate_identity_id
fi

# Do not continue in case halow init has not finished
while ps aux | grep [i]nit_halow > /dev/null; do
sleep 1
done

echo "set bridge ip"
generate_br_lan_ip

Expand Down

0 comments on commit 8f75053

Please sign in to comment.