aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-04-17 21:37:05 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-04-17 21:37:36 +0200
commita74d9c29c735c14d93302cb06257f7d22d8516f2 (patch)
tree8be3485d7bc85e361bc71711ff10799fb08144b2
parentec7850b5f2803fc3964a5855695a0a3895a79b4a (diff)
downloaddesktop-autoloader-a74d9c29c735c14d93302cb06257f7d22d8516f2.zip
desktop-autoloader-a74d9c29c735c14d93302cb06257f7d22d8516f2.tar.gz
desktop-autoloader-a74d9c29c735c14d93302cb06257f7d22d8516f2.tar.bz2
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.
-rwxr-xr-xbin/desktop-autoloader9
-rw-r--r--contrib/desktop-autoloader.default3
2 files changed, 12 insertions, 0 deletions
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
diff --git a/contrib/desktop-autoloader.default b/contrib/desktop-autoloader.default
index c41a590..c26c15f 100644
--- a/contrib/desktop-autoloader.default
+++ b/contrib/desktop-autoloader.default
@@ -6,6 +6,9 @@
# The autoloader is disabled by default. Enable it here (s/false/true/).
#DESKTOP_AUTOLOADER_ENABLED=false
+# Only run the Desktop Autoloader if the available RAM is above this threshold (in MiB)
+#REQUIRED_MEMORY_THRESHOLD=2048
+
# The virtual display to be used for the autoloader session.
AUTOLOAD_DISPLAY=:20