Evgeniy Zverev 1 год назад
Родитель
Сommit
6516adfe13
1 измененных файлов с 22 добавлено и 27 удалено
  1. 22 27
      compose/bin/configure-linux

+ 22 - 27
compose/bin/configure-linux

@@ -1,35 +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}')
+# Check if the script is running on Linux
+if [[ "$OSTYPE" == "linux-gnu"* ]]; then
+    # Get the IP address from the Docker container
+    docker_ip=$(docker run --rm alpine ip route | awk 'NR==1 {print $3}')
 
-# Check if the IP address already exists in /etc/hosts
-if grep -q "$docker_ip host.docker.internal" /etc/hosts; then
-    echo "The entry already exists in /etc/hosts. No action needed."
-else
-    # 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"
-fi
-
-# 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."
+    # Check if the IP address already exists in /etc/hosts
+    if grep -q "$docker_ip host.docker.internal" /etc/hosts; then
+        echo "The entry already exists in /etc/hosts. No action needed."
     else
-        echo "The setting vm.max_map_count=262144 already exists in /etc/sysctl.conf."
+        # 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"
     fi
+
+    # 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
+elif [[ "$OSTYPE" == "darwin"* ]]; then
+    echo "This script is designed for Linux and may not work properly on macOS."
+else
+    echo "Unsupported operating system."
 fi
 
 echo "Tasks completed successfully"
+