Skip to content

Commit 6516adf

Browse files
changed script name
1 parent 041f554 commit 6516adf

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

compose/bin/configure-linux

+22-27
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
11
#!/bin/bash
22

3-
# Get the IP address from the Docker container
4-
docker_ip=$(docker run --rm alpine ip route | awk 'NR==1 {print $3}')
3+
# Check if the script is running on Linux
4+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
5+
# Get the IP address from the Docker container
6+
docker_ip=$(docker run --rm alpine ip route | awk 'NR==1 {print $3}')
57

6-
# Check if the IP address already exists in /etc/hosts
7-
if grep -q "$docker_ip host.docker.internal" /etc/hosts; then
8-
echo "The entry already exists in /etc/hosts. No action needed."
9-
else
10-
# Add a new entry to /etc/hosts
11-
echo "$docker_ip host.docker.internal" | sudo tee -a /etc/hosts
12-
echo "A new entry in the /etc/hosts file has been created"
13-
fi
14-
15-
# Ask the user whether to execute the iptables command
16-
read -p "Do you want to open port 9003 for xdebug? (y/n): " choice
17-
if [ "$choice" == "y" ]; then
18-
sudo iptables -A INPUT -p tcp --dport 9003 -j ACCEPT
19-
echo "Port 9003 has been opened for xdebug."
20-
fi
21-
22-
# Ask the user whether to increase the virtual memory map count for Elasticsearch
23-
read -p "Do you need to increase the virtual memory map count for Elasticsearch? (y/n): " vm_choice
24-
if [ "$vm_choice" == "y" ]; then
25-
# Check if the setting already exists in /etc/sysctl.conf
26-
if ! grep -q "vm.max_map_count=262144" /etc/sysctl.conf; then
27-
echo "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.conf
28-
sudo sysctl -p
29-
echo "The virtual memory map count has been increased for Elasticsearch."
8+
# Check if the IP address already exists in /etc/hosts
9+
if grep -q "$docker_ip host.docker.internal" /etc/hosts; then
10+
echo "The entry already exists in /etc/hosts. No action needed."
3011
else
31-
echo "The setting vm.max_map_count=262144 already exists in /etc/sysctl.conf."
12+
# Add a new entry to /etc/hosts
13+
echo "$docker_ip host.docker.internal" | sudo tee -a /etc/hosts
14+
echo "A new entry in the /etc/hosts file has been created"
3215
fi
16+
17+
# Ask the user whether to execute the iptables command
18+
read -p "Do you want to open port 9003 for xdebug? (y/n): " choice
19+
if [ "$choice" == "y" ]; then
20+
sudo iptables -A INPUT -p tcp --dport 9003 -j ACCEPT
21+
echo "Port 9003 has been opened for xdebug."
22+
fi
23+
elif [[ "$OSTYPE" == "darwin"* ]]; then
24+
echo "This script is designed for Linux and may not work properly on macOS."
25+
else
26+
echo "Unsupported operating system."
3327
fi
3428

3529
echo "Tasks completed successfully"
30+

0 commit comments

Comments
 (0)