summaryrefslogtreecommitdiff
path: root/update_hosts
diff options
context:
space:
mode:
authorgrothedev <grothedev@gmail.com>2021-08-05 11:42:21 -0500
committergrothedev <grothedev@gmail.com>2021-08-05 11:42:21 -0500
commit35fdfb2f5df7d542c0a78d6ab3ffc24deb6ca78d (patch)
tree94a0f5f329843807fc7fae47ab77f2ab87790be5 /update_hosts
parent7939f26645643dfa10f9a2189b509298bf165948 (diff)
added systemd services and host update script
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
+