[rc.local] separate configuration migration and grub installation logic (#5528)

To address issue #5525

Explicitly control the grub installation requirement when it is needed.
We have scenario where configuration migration happened but grub
installation is not required.

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
This commit is contained in:
Ying Xie 2020-10-03 23:00:39 -07:00 committed by Ying Xie
parent 4c80d996ba
commit 9ea38c417c

View File

@ -184,6 +184,7 @@ logger "SONiC version ${SONIC_VERSION} starting up..."
# If the machine.conf is absent, it indicates that the unit booted # If the machine.conf is absent, it indicates that the unit booted
# into SONiC from another NOS. Extract the machine.conf from ONIE. # into SONiC from another NOS. Extract the machine.conf from ONIE.
grub_installation_needed=""
if [ ! -e /host/machine.conf ]; then if [ ! -e /host/machine.conf ]; then
onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//') onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//')
mkdir -p /mnt/onie-boot mkdir -p /mnt/onie-boot
@ -198,6 +199,7 @@ if [ ! -e /host/machine.conf ]; then
eval val='$'onie_$var eval val='$'onie_$var
echo "onie_${var}=${val}" >> /host/machine.conf echo "onie_${var}=${val}" >> /host/machine.conf
done done
grub_installation_needed="TRUE"
fi fi
umount /mnt/onie-boot umount /mnt/onie-boot
@ -256,7 +258,7 @@ if [ -f $FIRST_BOOT_FILE ]; then
# If the unit booted into SONiC from another NOS's grub, # If the unit booted into SONiC from another NOS's grub,
# we now install a grub for SONiC. # we now install a grub for SONiC.
if [ -n "$onie_platform" ] && [ -n "$migration" ]; then if [ -n "$onie_platform" ] && [ -n "$grub_installation_needed" ]; then
grub_bin=$(ls /host/image-$SONIC_VERSION/platform/x86_64-grub/grub-pc-bin*.deb 2> /dev/null) grub_bin=$(ls /host/image-$SONIC_VERSION/platform/x86_64-grub/grub-pc-bin*.deb 2> /dev/null)
if [ -z "$grub_bin" ]; then if [ -z "$grub_bin" ]; then