Skip to content

Commit

Permalink
fix(distrib): customize-installation.sh to always patch interface nam…
Browse files Browse the repository at this point in the history
…es 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 <[email protected]>

* fix: removed unecessary patch

Signed-off-by: Marcello Martina <[email protected]>

---------

Signed-off-by: Marcello Martina <[email protected]>
(cherry picked from commit 40604a1)

Co-authored-by: Marcello Rinaldo Martina <[email protected]>
  • Loading branch information
github-actions[bot] and marcellorinaldo authored Jun 13, 2024
1 parent 3d2e6a3 commit d6d326c
Showing 1 changed file with 35 additions and 16 deletions.
51 changes: 35 additions & 16 deletions kura/distrib/src/main/resources/common/customize-installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d6d326c

Please sign in to comment.