Skip to content

Commit fb0c9fe

Browse files
Millydliappis
authored andcommitted
Don't fail init script if /proc/.../max_map_count absent (elastic#35933)
Currently init scripts fail when `/proc/sys/vm/max_map_count` is not present with `-bash: [: too many arguments`. Fix conditional logic to avoid trying to set the `max_map_count` sysctl if not present. Relates elastic#27236
1 parent 032bcf9 commit fb0c9fe

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

distribution/packages/src/deb/init.d/elasticsearch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ case "$1" in
122122
ulimit -l $MAX_LOCKED_MEMORY
123123
fi
124124

125-
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count -a "$MAX_MAP_COUNT" -gt $(cat /proc/sys/vm/max_map_count) ]; then
125+
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ] && [ "$MAX_MAP_COUNT" -gt $(cat /proc/sys/vm/max_map_count) ]; then
126126
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
127127
fi
128128

distribution/packages/src/rpm/init.d/elasticsearch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ start() {
9090
if [ -n "$MAX_LOCKED_MEMORY" ]; then
9191
ulimit -l $MAX_LOCKED_MEMORY
9292
fi
93-
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count -a "$MAX_MAP_COUNT" -gt $(cat /proc/sys/vm/max_map_count) ]; then
93+
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ] && [ "$MAX_MAP_COUNT" -gt $(cat /proc/sys/vm/max_map_count) ]; then
9494
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
9595
fi
9696

0 commit comments

Comments
 (0)