Created
August 3, 2023 10:01
-
-
Save shubham-kshetre/1e911450ab9511678356f7f2248283fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while true; do | |
# Get the current IP address of the server | |
NEW_IP=$(ip addr show | awk '/inet .* global/{split($2,a,"/"); print a[1]; exit}') | |
DOMAIN="erium.local" | |
HOSTS_FILE="/etc/hosts" | |
sudo sed -i "/$DOMAIN/d" $HOSTS_FILE | |
echo "$NEW_IP $DOMAIN" | sudo tee -a $HOSTS_FILE | |
# Wait for 5 seconds | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment