diff options
| -rwxr-xr-x | update_hosts | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/update_hosts b/update_hosts index 0b3cc5a..8754b7a 100755 --- a/update_hosts +++ b/update_hosts @@ -3,15 +3,19 @@ # this script updates hosts in /etc/hosts # currently the only applicable host is my homeserver (local or remote ip) -localcheck=`nmap -sn 192.168.1.0/24 | grep debian` +while [[ true ]]; do + localcheck=`nmap -sn 192.168.1.0/24 | grep debian` -if [[ $localcheck ]]; then - hb_ip=`echo $localcheck | sed 's/.*(\(.*\))/\1/g'` -else - hb_ip=`ping grothe.ddns.net -c 1 | grep PING | awk '{print $3}' | sed 's/(\|)//g'` -fi + if [[ $localcheck ]]; then + hb_ip=`echo $localcheck | sed 's/.*(\(.*\))/\1/g'` + else + hb_ip=`ping grothe.ddns.net -c 1 | grep PING | awk '{print $3}' | sed 's/(\|)//g'` + fi -#sed -i 's/'${hb_ip}'.*//g' /etc/hosts -sed -i 's/.*hb//g' /etc/hosts -echo "${hb_ip} hb" >> /etc/hosts + #sed -i 's/'${hb_ip}'.*//g' /etc/hosts + sed -i '/.*hb/d' /etc/hosts + echo "${hb_ip} hb" >> /etc/hosts + sleep 360 + +done |
