with 5c9cc7b7f8920944a413644e1c2ea23bfe655bcb we changed the default
value from ~650 to 4096 kilobyte on 32mb-RAM-devices. This makes them
hardly useable with a lot of oom-crashes. Fix that and keep the default.
For devices with more than 32mb we keep the behaviour and tweak the value.
We dont suppress output of sysctl-command, so the use has a chance to spot it.

While we are at it, localize vars and read the memory without AWK/nonforking.

Signed-off-by: Bastian Bittorf <b...@npl.de>
---
 package/base-files/files/etc/init.d/sysctl | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/package/base-files/files/etc/init.d/sysctl 
b/package/base-files/files/etc/init.d/sysctl
index a0daec0..c3b48f4 100755
--- a/package/base-files/files/etc/init.d/sysctl
+++ b/package/base-files/files/etc/init.d/sysctl
@@ -4,17 +4,19 @@
 START=11
 
 set_vm_min_free() {
-       mem="$(grep MemTotal /proc/meminfo  | awk '{print $2}')"
-       if [ "$mem" -gt 65536 ]; then # 128M
+       local mem value
+
+       read -r _ mem _ </proc/meminfo
+
+       if [ "$mem" -gt 65536 ]; then   # 128M
                val=16384
-       elif [ "$mem" -gt 32768 ]; then # 64M
+       elif [ "$mem" -gt 32768 ]; then # 64M
                val=8192
-       elif [ "$mem" -gt 16384 ]; then # 32M
-               val=4096
        else
                return
        fi
-       sysctl -qw vm.min_free_kbytes="$val"
+
+       sysctl -w vm.min_free_kbytes="$val"
 }
 
 start() {
-- 
2.7.4


_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to