Skip to content

Instantly share code, notes, and snippets.

@shubham-kshetre
Created August 3, 2023 10:01
Show Gist options
  • Save shubham-kshetre/1e911450ab9511678356f7f2248283fd to your computer and use it in GitHub Desktop.
Save shubham-kshetre/1e911450ab9511678356f7f2248283fd to your computer and use it in GitHub Desktop.
#!/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