Skip to content

Commit

Permalink
feat: dynamic ram assignment when over 1GB (#4921)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
GregoryIvo authored Nov 2, 2023
1 parent ca23c48 commit 17814c7
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion kura/distrib/src/main/resources/common/customize-installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

# 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

0 comments on commit 17814c7

Please sign in to comment.