#!/bin/sh # # kiosk-uname sets the host name based on DNS and eth0's IP address # # chkconfig: 345 26 24 # description: sets the host name based on DNS and eth0's IP address # If the host name is still set to "localhost", try harder. # if [ `hostname` = localhost ]; then addr=`/sbin/ifconfig eth0 | sed -n 's/^.*addr:\([0-9.]*\).*/\1/p'` # name=`nslookup $addr | sed -n 's/^Name: *\([^.]*\).*$/\1/p'` name=`/usr/bin/host $addr | sed -n 's/^.* pointer *\([^.]*\).*$/\1/p'` if [ "$name" = "" ]; then echo "unable to determine hostname of \"$addr\"!" >&2 else echo "setting hostname to \"$name\"..." >&2 hostname $name fi fi exit 0