aboutsummaryrefslogtreecommitdiffstats
path: root/main/util-vserver/util-vserver.post-install
diff options
context:
space:
mode:
Diffstat (limited to 'main/util-vserver/util-vserver.post-install')
-rw-r--r--main/util-vserver/util-vserver.post-install15
1 files changed, 15 insertions, 0 deletions
diff --git a/main/util-vserver/util-vserver.post-install b/main/util-vserver/util-vserver.post-install
new file mode 100644
index 0000000000..9c8aad1e4c
--- /dev/null
+++ b/main/util-vserver/util-vserver.post-install
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+if [ -f /etc/vservers/.defaults/rlimits/nproc ]; then
+ exit 0
+fi
+
+# calculate the nproc limit from amount of ram
+memtotal=$(awk '$1 == "MemTotal:" {print $2}' /proc/meminfo 2>/dev/null)
+nproc=$(( ${memtotal:-524288} / 256 ))
+
+# set a "sane" default nproc limit
+echo "Setting default nproc limit to $nproc"
+mkdir -p /etc/vservers/.defaults/rlimits
+echo $nproc > /etc/vservers/.defaults/rlimits/nproc
+