From a74d9c29c735c14d93302cb06257f7d22d8516f2 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Tue, 17 Apr 2018 21:37:05 +0200 Subject: Provide means to configure a required memory threshold. If the system is below that threshold, desktop autoloader won't run. Starting with a default value of 2048MiB for this threshold. --- bin/desktop-autoloader | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'bin') diff --git a/bin/desktop-autoloader b/bin/desktop-autoloader index 9a13de1..0ab6390 100755 --- a/bin/desktop-autoloader +++ b/bin/desktop-autoloader @@ -21,6 +21,7 @@ # Boston, MA 02110-1301 USA DESKTOP_AUTOLOADER_ENABLE=false +REQUIRED_MEMORY_THRESHOLD=2048 AUTOLOAD_DISPLAY=":20" DESKTOP_SESSION_MANAGER="x-session-manager" @@ -38,6 +39,14 @@ if ! is_true "$DESKTOP_AUTOLOADER_ENABLE"; then exit 0 fi +AVAILABLE_SYSTEM_MEMORY=$(free -m | grep Mem | awk '{print $2}') + +if [ ! "${AVAILABLE_SYSTEM_MEMORY}" -gt "${REQUIRED_MEMORY_THRESHOLD}" ]; then + echo "Desktop Autoloader is configured to only run on systems with more than ${REQUIRED_MEMORY_THRESHOLD} MiB of RAM." + echo "This system only has ${AVAILABLE_SYSTEM_MEMORY} MiB." + exit 0 +fi + # clean up .xsession-errors for a new launch (in case this tool is used # on a non-diskless machine... if [ "$(id -un)" == "desktop-autoloader" ]; then -- cgit v1.2.3