From 7b64a5c2c80add9c4c4beef085b8396ce7824edc Mon Sep 17 00:00:00 2001 From: Alexander Reelsen Date: Fri, 5 Dec 2014 14:37:08 +0100 Subject: [PATCH] Packaging: Check if proc file exists before calling sysctl The packaged init scripts could return an error, if the file /proc/sys/vm/max_map_count was not existing and we still called sysctl. This is primarly to prevent confusing error messages when elasticsearch is started under virtualized environments without a proc file system. Closes #4978 --- src/deb/init.d/elasticsearch | 2 +- src/rpm/init.d/elasticsearch | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/deb/init.d/elasticsearch b/src/deb/init.d/elasticsearch index ecb6547cdd7..88005e35db9 100755 --- a/src/deb/init.d/elasticsearch +++ b/src/deb/init.d/elasticsearch @@ -157,7 +157,7 @@ case "$1" in ulimit -l $MAX_LOCKED_MEMORY fi - if [ -n "$MAX_MAP_COUNT" ]; then + if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ]; then sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT fi diff --git a/src/rpm/init.d/elasticsearch b/src/rpm/init.d/elasticsearch index 5cd75cee7cf..c63a1eb18d1 100644 --- a/src/rpm/init.d/elasticsearch +++ b/src/rpm/init.d/elasticsearch @@ -77,7 +77,7 @@ start() { if [ -n "$MAX_LOCKED_MEMORY" ]; then ulimit -l $MAX_LOCKED_MEMORY fi - if [ -n "$MAX_MAP_COUNT" ]; then + if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ]; then sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT fi if [ -n "$WORK_DIR" ]; then