summaryrefslogtreecommitdiff
path: root/update_hosts
diff options
context:
space:
mode:
Diffstat (limited to 'update_hosts')
-rwxr-xr-xupdate_hosts16
1 files changed, 16 insertions, 0 deletions
diff --git a/update_hosts b/update_hosts
new file mode 100755
index 0000000..745eb68
--- /dev/null
+++ b/update_hosts
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# 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`
+
+if [[ $localcheck ]]; then
+ hb_ip=`echo $localcheck | sed 's/.*(\(.*\))/\1/g'`
+else
+ hb_ip=`ping grothe.ddns.net -c 1 | sed 's/bytes from.*(\(.*\)).*/\1/g'`
+fi
+
+sed -i 's/'${hb_ip}'.*//g'
+echo '${hb_ip} hb' >> /etc/hosts
+