#!/bin/bash

#Update elasticsearch Xms and Xmx
#Elasticsearch: You should always set the min and max JVM heap size to the same value.
if ! sed -i "s/-Xms[0-9]g\+/-Xms4g/" /etc/elasticsearch/jvm.options; then
    echo "Error: Set Xms option in /etc/elasticsearch/jvm.options failed."
fi

if ! sed -i "s/-Xmx[0-9]g\+/-Xmx4g/" /etc/elasticsearch/jvm.options; then
    echo "Error: Set Xmx option in /etc/elasticsearch/jvm.options failed."
fi

systemctl enable elasticsearch.service
systemctl restart elasticsearch.service
