#!/bin/sh
# Filename:     /etc/dhcp/dhclient-exit-hooks.d/hostname
# Purpose:      Used by dhclient-script to set the hostname of the system
#               to match the DNS information for the host as provided by  DHCP. 

case "$reason" in
    BOUND|RENEW|REBIND|REBOOT)
        # Extract the hostname supplied by the DHCP server - make sure its not empty
        if [ ! -z $new_host_name ] 
        then                                       
                echo $new_host_name > /etc/hostname
                hostname $new_host_name
                /etc/init.d/nmbd restart
                /etc/init.d/avahi-daemon restart
        fi
        ;;

    *)
        ;;
esac


