extra-settings 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. # Get the IP address from the Docker container
  3. docker_ip=$(docker run --rm alpine ip route | awk 'NR==1 {print $3}')
  4. # Check if the IP address already exists in /etc/hosts
  5. if grep -q "$docker_ip host.docker.internal" /etc/hosts; then
  6. echo "The entry already exists in /etc/hosts. No action needed."
  7. else
  8. # Add a new entry to /etc/hosts
  9. echo "$docker_ip host.docker.internal" | sudo tee -a /etc/hosts
  10. echo "A new entry in the /etc/hosts file has been created"
  11. fi
  12. # Ask the user whether to execute the iptables command
  13. read -p "Do you want to open port 9003 for xdebug? (y/n): " choice
  14. if [ "$choice" == "y" ]; then
  15. sudo iptables -A INPUT -p tcp --dport 9003 -j ACCEPT
  16. echo "Port 9003 has been opened for xdebug."
  17. fi
  18. # Ask the user whether to increase the virtual memory map count for Elasticsearch
  19. read -p "Do you need to increase the virtual memory map count for Elasticsearch? (y/n): " vm_choice
  20. if [ "$vm_choice" == "y" ]; then
  21. # Check if the setting already exists in /etc/sysctl.conf
  22. if ! grep -q "vm.max_map_count=262144" /etc/sysctl.conf; then
  23. echo "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.conf
  24. sudo sysctl -p
  25. echo "The virtual memory map count has been increased for Elasticsearch."
  26. else
  27. echo "The setting vm.max_map_count=262144 already exists in /etc/sysctl.conf."
  28. fi
  29. fi
  30. echo "Tasks completed successfully"