File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -240,6 +240,7 @@ iface eth0 inet dhcp
240240EOF
241241
242242sudo cp files/dhcp/rfc3442-classless-routes $FILESYSTEM_ROOT /etc/dhcp/dhclient-exit-hooks.d
243+ sudo cp files/dhcp/sethostname $FILESYSTEM_ROOT /etc/dhcp/dhclient-exit-hooks.d/
243244
244245if [ -f sonic_debian_extension.sh ]; then
245246 ./sonic_debian_extension.sh $FILESYSTEM_ROOT
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # This script is to update hostname of the system.
3+
4+ if [ " $reason " != BOUND ] && [ " $reason " != RENEW ] \
5+ && [ " $reason " != REBIND ] && [ " $reason " != REBOOT ]
6+ then
7+ exit 0
8+ fi
9+
10+ current_host_name=` hostname -s`
11+
12+ if [ " $current_host_name " != " $new_host_name " ]
13+ then
14+ echo $new_host_name > /etc/hostname
15+ line_to_replace=` grep 127.0.0.1.* $current_host_name /etc/hosts`
16+ new_line=` echo $line_to_replace | sed " s/$current_host_name /$new_host_name /" `
17+ sed -i " s/$line_to_replace /$new_line /" /etc/hosts
18+
19+ hostname -F /etc/hostname
20+ fi
You can’t perform that action at this time.
0 commit comments