alice-auth/usr/bin/ldap-hostname

12 lines
259 B
Plaintext
Raw Normal View History

2024-11-18 10:32:21 -03:00
#!/bin/sh
IP=$(hostname -I | awk '{print $1}')
HOSTNAME=$(getent hosts | grep $IP | awk '{print $2}')
if [ -n "$HOSTNAME" ]; then
hostnamectl set-hostname "$HOSTNAME"
echo "Hostname set to $HOSTNAME"
else
echo "Hostname not found for IP $IP"
fi