From 3ee2aa723b3659f08cf9f2339088f516acaa71b8 Mon Sep 17 00:00:00 2001 From: Evgeniy Zverev Date: Mon, 4 Dec 2023 19:26:38 +0200 Subject: [PATCH] Add extra-settings script --- compose/bin/extra-settings | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 compose/bin/extra-settings diff --git a/compose/bin/extra-settings b/compose/bin/extra-settings new file mode 100755 index 000000000..64b051322 --- /dev/null +++ b/compose/bin/extra-settings @@ -0,0 +1,30 @@ +#!/bin/bash + +# Get the IP address from the Docker container +docker_ip=$(docker run --rm alpine ip route | awk 'NR==1 {print $3}') + +# Add a new entry to /etc/hosts +echo "$docker_ip host.docker.internal" | sudo tee -a /etc/hosts +echo "A new entry in the /etc/hosts file has been created" + +# Ask the user whether to execute the iptables command +read -p "Do you want to open port 9003 for xdebug? (y/n): " choice +if [ "$choice" == "y" ]; then + sudo iptables -A INPUT -p tcp --dport 9003 -j ACCEPT + echo "Port 9003 has been opened for xdebug." +fi + +# Ask the user whether to increase the virtual memory map count for Elasticsearch +read -p "Do you need to increase the virtual memory map count for Elasticsearch? (y/n): " vm_choice +if [ "$vm_choice" == "y" ]; then + # Check if the setting already exists in /etc/sysctl.conf + if ! grep -q "vm.max_map_count=262144" /etc/sysctl.conf; then + echo "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.conf + sudo sysctl -p + echo "The virtual memory map count has been increased for Elasticsearch." + else + echo "The setting vm.max_map_count=262144 already exists in /etc/sysctl.conf." + fi +fi + +echo "Tasks completed successfully"