Update hostname via reverse DNS lookup

Should help differentiate systems
This commit is contained in:
2Shirt 2018-09-12 17:44:23 -06:00
parent 56e354f124
commit 34925a72c0
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 16 additions and 0 deletions

View file

@ -0,0 +1,15 @@
#!/bin/bash
IP="$(ip a show scope global \
| grep inet \
| head -1 \
| sed -r 's#.*inet ([0-9]+.[0-9]+.[0-9]+.[0-9]+.)/.*#\1#')"
HOSTNAME="$(dig +noall +answer +short -x "$IP" \
| sed 's/\.$//')"
# Set hostname and renew DHCP lease
sudo hostnamectl set-hostname "${HOSTNAME}"
sudo dhclient -r
sleep 1
sudo dhclient

View file

@ -12,6 +12,7 @@ conky -d
nm-applet &
cbatticon &
volumeicon &
$HOME/.update_hostname
connect-to-network &
(sleep 5s && killall dunst) &
$HOME/.urxvt_default_res &