-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
configure-linux
executable file
·26 lines (22 loc) · 996 Bytes
/
configure-linux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env bash
if [ "$(uname)" == "Darwin" ]; then
echo "This script is designed for Linux and will not work properly on macOS."
else
# 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 -r -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
echo "Tasks completed successfully"
fi