I'm trying to change my hostname at startup of an image to the /24 - /32 IPv4 address. I've come up with the following script, but HNAME remains NULL:
#!/bin/sh
echo "Changing hostname to IP-related"
HNAME=ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d. -f4 | awk '{ print $1 }'
echo "Proposed hostname is: $HNAME"
echo
hostname=$HNAME
echo "The new hostname is $HOST_NAME"
echo
HNAME=$(ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d. -f4 | awk '{ print $1 }')