From 35fdfb2f5df7d542c0a78d6ab3ffc24deb6ca78d Mon Sep 17 00:00:00 2001 From: grothedev Date: Thu, 5 Aug 2021 11:42:21 -0500 Subject: added systemd services and host update script --- update_hosts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 update_hosts (limited to 'update_hosts') 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 + -- cgit v1.2.3