From d6d326c8d7d280ee7d5181af05078af1f0fbb5d9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 09:10:38 +0200 Subject: [PATCH] fix(distrib): customize-installation.sh to always patch interface names on snapshot_0.xml and iptables [backport release-5.5.0] (#5278) fix(distrib): customize-installation.sh to always patch interface names on snapshot_0.xml and iptables (#5275) * fix(distrib): customize-installation.sh to patch interface names even on recognized devices Signed-off-by: Marcello Martina * fix: removed unecessary patch Signed-off-by: Marcello Martina --------- Signed-off-by: Marcello Martina (cherry picked from commit 40604a1db7d3f9e1acf85dbfee136453dc782090) Co-authored-by: Marcello Rinaldo Martina <39562568+marcellorinaldo@users.noreply.github.com> --- .../common/customize-installation.sh | 51 +++++++++++++------ 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/kura/distrib/src/main/resources/common/customize-installation.sh b/kura/distrib/src/main/resources/common/customize-installation.sh index 05371c01536..6b7168b6a99 100644 --- a/kura/distrib/src/main/resources/common/customize-installation.sh +++ b/kura/distrib/src/main/resources/common/customize-installation.sh @@ -38,6 +38,37 @@ setup_libudev() { fi } +customize_kura_properties() { + local BOARD=$1 + + sed -i "s/device_name/${BOARD}/g" "/opt/eclipse/kura/framework/kura.properties" + + if python3 -V > /dev/null 2>&1 + then + python3 /opt/eclipse/kura/install/find_net_interfaces.py /opt/eclipse/kura/framework/kura.properties + else + echo "python3 not found. Could not edit the primary network interface name in /opt/eclipse/kura/framework/kura.properties. Defaulted to eth0." + fi +} + +customize_network_interfaces() { + local BOARD=$1 + local TO_BE_PATCHED=() + + TO_BE_PATCHED+=("/opt/eclipse/kura/user/snapshots/snapshot_0.xml") + TO_BE_PATCHED+=("/opt/eclipse/kura/.data/iptables") + + if [ ${#TO_BE_PATCHED[@]} -gt 0 ] + then + if python3 -V > /dev/null 2>&1 + then + python3 "/opt/eclipse/kura/install/find_net_interfaces.py" "${TO_BE_PATCHED[@]}" + else + echo "python3 not found. The following files may have wrong interface names: ${TO_BE_PATCHED[*]}. Please correct them manually if they mismatch." + fi + fi +} + KURA_PLATFORM=$( uname -m ) sed -i "s/kura_platform/${KURA_PLATFORM}/g" "/opt/eclipse/kura/framework/kura.properties" @@ -73,23 +104,11 @@ fi mv "/opt/eclipse/kura/install/jdk.dio.properties-${BOARD}" "/opt/eclipse/kura/framework/jdk.dio.properties" mv "/opt/eclipse/kura/install/snapshot_0.xml-${BOARD}" "/opt/eclipse/kura/user/snapshots/snapshot_0.xml" mv "/opt/eclipse/kura/install/iptables-${BOARD}" "/opt/eclipse/kura/.data/iptables" -sed -i "s/device_name/${BOARD}/g" "/opt/eclipse/kura/framework/kura.properties" -if python3 -V > /dev/null 2>&1 -then - python3 /opt/eclipse/kura/install/find_net_interfaces.py /opt/eclipse/kura/framework/kura.properties -else - echo "python3 not found. Could not edit the primary netowrk interface name in /opt/eclipse/kura/framework/kura.properties. Defaulted to eth0." -fi -if [ ${BOARD} = "generic-device" ]; then - # replace snapshot_0, iptables.init, and kura.properties with correct interface names - if python3 -V > /dev/null 2>&1 - then - python3 /opt/eclipse/kura/install/find_net_interfaces.py /opt/eclipse/kura/user/snapshots/snapshot_0.xml /opt/eclipse/kura/.data/iptables - else - echo "python3 not found. snapshot_0.xml, and iptables.init files may have wrong interface names. Default is eth0 and wlan0. Please correct them manually if they mismatch." - fi - +customize_kura_properties "${BOARD}" +customize_network_interfaces "${BOARD}" + +if [ ${BOARD} = "generic-device" ]; then # dynamic RAM assignment RAM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}') RAM_MB=$(expr $RAM_KB / 1024)