Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ iface eth0 inet dhcp
EOF

sudo cp files/dhcp/rfc3442-classless-routes $FILESYSTEM_ROOT/etc/dhcp/dhclient-exit-hooks.d
sudo cp files/dhcp/sethostname $FILESYSTEM_ROOT/etc/dhcp/dhclient-exit-hooks.d/

if [ -f sonic_debian_extension.sh ]; then
./sonic_debian_extension.sh $FILESYSTEM_ROOT
Expand Down
20 changes: 20 additions & 0 deletions files/dhcp/sethostname
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# This script is to update hostname of the system.

if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] \
&& [ "$reason" != REBIND ] && [ "$reason" != REBOOT ]
then
exit 0
fi

current_host_name=`hostname -s`

if [ "$current_host_name" != "$new_host_name" ]
then
echo $new_host_name > /etc/hostname
line_to_replace=`grep 127.0.0.1.*$current_host_name /etc/hosts`
new_line=`echo $line_to_replace | sed "s/$current_host_name/$new_host_name/"`
sed -i "s/$line_to_replace/$new_line/" /etc/hosts

hostname -F /etc/hostname
fi