From 17814c7cfe542195c7f0c76301677df73cfbb45c Mon Sep 17 00:00:00 2001 From: G_Ivo Date: Thu, 2 Nov 2023 11:26:10 -0400 Subject: [PATCH] feat: dynamic ram assignment when over 1GB (#4921) * feat: dynamic ram assignment when over 1GB * fix: update if statement syntax * refactor: added for loop for string replacement * refactor: echo string to be more descriptive * feat: will default profile to 256 if less then 1GB of ram * fix: moved ram replacement string --- .../common/customize-installation.sh | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/kura/distrib/src/main/resources/common/customize-installation.sh b/kura/distrib/src/main/resources/common/customize-installation.sh index 13dfd1922cb..5c0e2f6a551 100644 --- a/kura/distrib/src/main/resources/common/customize-installation.sh +++ b/kura/distrib/src/main/resources/common/customize-installation.sh @@ -61,4 +61,23 @@ if [ ${BOARD} = "generic-device" ]; then 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 -fi \ No newline at end of file + + # dynamic RAM assignment + RAM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}') + RAM_MB=$(expr $RAM_KB / 1024) + RAM_MB_FOR_KURA=$(expr $RAM_MB / 4) + + if [ "$RAM_MB" -lt 1024 ]; then + RAM_REPLACEMENT_STRING="-Xms256m -Xmx256m" + fi + + echo "Setting kura RAM to ${RAM_REPLACEMENT_STRING}" + start_scripts_to_change=("start_kura.sh" "start_kura_debug.sh" "start_kura_background.sh") + + RAM_REPLACEMENT_STRING="-Xms${RAM_MB_FOR_KURA}m -Xmx${RAM_MB_FOR_KURA}m" + for installer_name in "${start_scripts_to_change[@]}"; do + echo "Updating RAM values for $installer_name" + sed -i "s/-Xms[0-9]*m -Xmx[0-9]*m/$RAM_REPLACEMENT_STRING/g" "/opt/eclipse/kura/bin/$installer_name" + done + +fi