sonic-buildimage/files/dhcp/sethostname
Taoyu Li ea372cc7c1 Add get_graph service to fetch minigraph automatically (#288)
- Add a functionality to get SNMP community from DHCP (option 224)
- Add a functionality to get minigraph from http service instead of using default minigraph
  - The url for graph service is passed through DHCP option 225
  - This feature is by default disabled. Modify rule/config to enable it on build time, or modify /etc/sonic/graph_service_url on run time.
- Fix a bug that getting hostname from DHCP is not working correctly
2017-02-17 13:47:01 -08:00

14 lines
412 B
Plaintext

case $reason in
BOUND|RENEW|REBIND|REBOOT)
current_host_name=`hostname -s`
if [ "$current_host_name" != "$new_host_name" ] && [ -n "$new_host_name" ]
then
echo $new_host_name > /etc/hostname
hostname -F /etc/hostname
sed -i "/\s$current_host_name$/d" /etc/hosts
echo "127.0.0.1 $new_host_name" >> /etc/hosts
fi
;;
esac