File tree 3 files changed +27
-0
lines changed
3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,11 @@ sudo cp $IMAGE_CONFIGS/interfaces/*.j2 $FILESYSTEM_ROOT/usr/share/sonic/template
120
120
# Copy initial interfaces configuration file, will be overwritten on first boot
121
121
sudo cp $IMAGE_CONFIGS /interfaces/init_interfaces $FILESYSTEM_ROOT /etc/network
122
122
123
+ # Copy hostname configuration scripts
124
+ sudo cp $IMAGE_CONFIGS /hostname/hostname-config.service $FILESYSTEM_ROOT /etc/systemd/system/
125
+ sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable hostname-config.service
126
+ sudo cp $IMAGE_CONFIGS /hostname/hostname-config.sh $FILESYSTEM_ROOT /usr/bin/
127
+
123
128
# Copy updategraph script and service file
124
129
sudo cp $IMAGE_CONFIGS /updategraph/updategraph.service $FILESYSTEM_ROOT /etc/systemd/system/
125
130
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable updategraph.service
Original file line number Diff line number Diff line change
1
+ [Unit]
2
+ Description =Update hostname based on configdb
3
+ Requires =database.service
4
+ After =database.service
5
+
6
+ [Service]
7
+ Type =oneshot
8
+ ExecStart =/usr/bin/hostname-config.sh
9
+
10
+ [Install]
11
+ WantedBy =multi-user.target
Original file line number Diff line number Diff line change
1
+ #! /bin/bash -e
2
+
3
+ CURRENT_HOSTNAME=` hostname`
4
+ HOSTNAME=` sonic-cfggen -d -v DEVICE_METADATA[\' localhost\' ][\' hostname\' ]`
5
+
6
+ echo $HOSTNAME > /etc/hostname
7
+ hostname -F /etc/hostname
8
+
9
+ sed -i " /\s$CURRENT_HOSTNAME $/d" /etc/hosts
10
+ echo " 127.0.0.1 $HOSTNAME " >> /etc/hosts
11
+
You can’t perform that action at this time.
0 commit comments