2018-02-06 16:59:15 -06:00
|
|
|
#!/bin/sh -x
|
2017-02-27 15:08:41 -06:00
|
|
|
#
|
|
|
|
# rc.local
|
|
|
|
#
|
|
|
|
# This script is executed at the end of each multiuser runlevel.
|
|
|
|
# Make sure that the script will "exit 0" on success or any other
|
|
|
|
# value on error.
|
|
|
|
#
|
|
|
|
# In order to enable or disable this script just change the execution
|
|
|
|
# bits.
|
|
|
|
#
|
|
|
|
# By default this script does nothing.
|
|
|
|
|
2020-07-31 19:59:09 -05:00
|
|
|
SONIC_VERSION=$(cat /etc/sonic/sonic_version.yml | grep "build_version" | sed -e "s/build_version: //g;s/'//g")
|
2018-06-28 07:29:14 -05:00
|
|
|
FIRST_BOOT_FILE="/host/image-${SONIC_VERSION}/platform/firsttime"
|
|
|
|
|
2020-07-31 19:59:09 -05:00
|
|
|
# Move sonic-environment to /etc/sonic
|
|
|
|
SONIC_CONFIG_DIR="/host/image-${SONIC_VERSION}/sonic-config"
|
|
|
|
SONIC_ENV_FILE=${SONIC_CONFIG_DIR}/sonic-environment
|
|
|
|
if [ -d ${SONIC_CONFIG_DIR} -a -f ${SONIC_ENV_FILE} ]; then
|
|
|
|
echo "moving file ${SONIC_ENV_FILE} to /etc/sonic" 1>&2
|
|
|
|
mv ${SONIC_ENV_FILE} /etc/sonic
|
|
|
|
fi
|
|
|
|
|
2018-03-08 18:42:41 -06:00
|
|
|
# In case the unit is migrating from another NOS, save the logs
|
|
|
|
log_migration() {
|
|
|
|
echo $1 >> /host/migration/migration.log
|
|
|
|
}
|
|
|
|
|
|
|
|
# Import files from another NOS's partition onto SONiC
|
|
|
|
nos_migration_import() {
|
|
|
|
[ -f $1 ] && cp $1 $2 || log_migration "ERROR: $1 not found!"
|
|
|
|
}
|
|
|
|
|
|
|
|
# While migrating form another NOS, we need to preserve the MAC addresses
|
|
|
|
# of eth0 (and eventually switchports).
|
|
|
|
# Update the eth0 mac and also the EEPROM using ethtool so that subsequent
|
|
|
|
# reboots use the NOS's mac.
|
|
|
|
# Input : mgmt_interface.cfg file imported from the previous NOS.
|
|
|
|
update_mgmt_interface_macaddr() {
|
|
|
|
mgmt_config=$1
|
|
|
|
if [ ! -f "$mgmt_config" ]; then
|
|
|
|
log_migration "ERROR : unable update eth0 MAC : $mgmt_config not found!"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Save the previous NOS's mac
|
|
|
|
old_mac=`ip link show eth0 | grep ether | awk '{print $2}'`
|
|
|
|
[ -z "$old_mac" ] && log_migration "Unable to retrieve old mac address !" && return
|
|
|
|
|
|
|
|
# Extract, validate and set the eth0's mac address for the current session
|
|
|
|
new_mac=$(grep "macaddr" $mgmt_config | awk -F'=' '{print $2}')
|
|
|
|
log_migration "Setting eth0 mac as $new_mac."
|
|
|
|
if [ `echo $new_mac | egrep "^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"` ]; then
|
|
|
|
ip link set eth0 down
|
|
|
|
ip link set eth0 address $new_mac
|
|
|
|
ip link set eth0 up
|
|
|
|
else
|
|
|
|
log_migration "ERROR: mac imported from NOS is invalid : $new_mac !"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Get the ethtool magic and offset for changing the mac address in the EEPROM
|
2020-09-08 14:29:02 -05:00
|
|
|
ethtool_magic=$(grep "ethtool_magic" $mgmt_config | awk -F'=' '{print $2}')
|
|
|
|
ethtool_offset=$(grep "ethtool_offset" $mgmt_config | awk -F'=' '{print $2}')
|
2018-03-08 18:42:41 -06:00
|
|
|
if [ -z "$ethtool_magic" ] || [ -z "$ethtool_offset" ]; then
|
|
|
|
log_migration "Unable to retrieve ethtool params ($ethtool_magic,$ethtool_offset)"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
log_migration "eth0 mac in EEPROM before update:"
|
|
|
|
ethtool -e eth0 offset $ethtool_offset length 6 >> /host/migration/migration.log
|
|
|
|
|
|
|
|
# Update the mac address in the EEPROM for subsequent reboots
|
|
|
|
# Write only changed octets
|
|
|
|
for i in 1 2 3 4 5 6; do
|
|
|
|
offset=$(($ethtool_offset+$i-1))
|
|
|
|
old_mac_octet="$(echo $old_mac | cut -d":" -f$i)"
|
|
|
|
new_mac_octet="$(echo $new_mac | cut -d":" -f$i)"
|
|
|
|
|
|
|
|
if [ "$old_mac_octet" != "$new_mac_octet" ]; then
|
|
|
|
ethtool -E eth0 magic $ethtool_magic offset $offset value 0x$new_mac_octet
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
log_migration "ERROR: unable to update eth0 EEPROM!"
|
|
|
|
log_migration "index $i, magic $ethtool_magic offset $offset, value $new_mac_octet"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
log_migration "eth0 mac in EEPROM after update:"
|
|
|
|
ethtool -e eth0 offset $ethtool_offset length 6 >> /host/migration/migration.log
|
|
|
|
}
|
|
|
|
|
2020-09-08 14:29:02 -05:00
|
|
|
migrate_nos_configuration()
|
|
|
|
{
|
|
|
|
rm -rf /host/migration
|
|
|
|
mkdir -p /host/migration
|
|
|
|
|
|
|
|
# Extract the previous NOS's partition that contains the migration artifacts
|
|
|
|
set -- $(cat /proc/cmdline)
|
|
|
|
for x in "$@"; do
|
|
|
|
case "$x" in
|
|
|
|
nos-config-part=*)
|
|
|
|
nos_dev="${x#nos-config-part=}"
|
|
|
|
;;
|
|
|
|
SONIC_BOOT_TYPE=fast*)
|
|
|
|
sonic_fast_reboot=true
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -n "$nos_dev" ]; then
|
|
|
|
# remove nos-config-part from cmdline
|
|
|
|
sed -r -i.bak "s/nos-config-part=[^[:space:]]+//" /host/grub/grub.cfg
|
|
|
|
|
2022-05-12 10:11:02 -05:00
|
|
|
# remove ssd-upgrader-part from cmdline
|
|
|
|
sed -r -i.bak "s/ssd-upgrader-part=[^[:space:]]+//" /host/grub/grub.cfg
|
|
|
|
|
2020-09-08 14:29:02 -05:00
|
|
|
# Mount the previous NOS's partition
|
|
|
|
NOS_DIR=/mnt/nos_migration
|
|
|
|
MG_GZFILE=$NOS_DIR/minigraph.xml.gz.base64.txt
|
|
|
|
MG_FILE=$NOS_DIR/minigraph.xml
|
|
|
|
ACL_GZFILE=$NOS_DIR/acl.json.gz.base64.txt
|
|
|
|
ACL_FILE=$NOS_DIR/acl.json
|
2021-07-14 19:56:35 -05:00
|
|
|
PORT_CONFIG_GZFILE=$NOS_DIR/port_config.json.gz.base64.txt
|
|
|
|
PORT_CONFIG_FILE=$NOS_DIR/port_config.json
|
2020-09-08 14:29:02 -05:00
|
|
|
SNMP_FILE=$NOS_DIR/snmp.yml
|
|
|
|
mkdir -p $NOS_DIR
|
|
|
|
|
|
|
|
mount $nos_dev $NOS_DIR
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
log_migration "ERROR: cannot mount $nos_dev"
|
|
|
|
else
|
|
|
|
|
|
|
|
# decode & unzip minigraph.xml.gz.base64.txt
|
|
|
|
[ -f $MG_GZFILE ] && /usr/bin/base64 -d $MG_GZFILE | /bin/gunzip > $MG_FILE
|
|
|
|
[ -f $ACL_GZFILE ] && /usr/bin/base64 -d $ACL_GZFILE | /bin/gunzip > $ACL_FILE
|
2021-07-14 19:56:35 -05:00
|
|
|
[ -f $PORT_CONFIG_GZFILE ] && /usr/bin/base64 -d $PORT_CONFIG_GZFILE | /bin/gunzip > $PORT_CONFIG_FILE
|
2020-09-08 14:29:02 -05:00
|
|
|
|
|
|
|
# Copy relevant files
|
|
|
|
nos_migration_import $NOS_DIR/mgmt_interface.cfg /host/migration
|
|
|
|
nos_migration_import $MG_FILE /host/migration
|
|
|
|
nos_migration_import $ACL_FILE /host/migration
|
2021-07-14 19:56:35 -05:00
|
|
|
nos_migration_import $PORT_CONFIG_FILE /host/migration
|
2020-09-08 14:29:02 -05:00
|
|
|
nos_migration_import $SNMP_FILE /host/migration
|
|
|
|
|
|
|
|
if [ "$sonic_fast_reboot" == true ]; then
|
|
|
|
mkdir -p /host/fast-reboot
|
|
|
|
nos_migration_import $NOS_DIR/arp.json /host/fast-reboot
|
|
|
|
nos_migration_import $NOS_DIR/fdb.json /host/fast-reboot
|
|
|
|
nos_migration_import $NOS_DIR/default_routes.json /host/fast-reboot
|
|
|
|
fi
|
|
|
|
|
|
|
|
umount $NOS_DIR
|
|
|
|
rmdir $NOS_DIR
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ -f /host/migration/mgmt_interface.cfg ] && update_mgmt_interface_macaddr /host/migration/mgmt_interface.cfg
|
|
|
|
|
|
|
|
migration="TRUE"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-06-28 07:29:14 -05:00
|
|
|
firsttime_exit() {
|
|
|
|
rm -rf $FIRST_BOOT_FILE
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# Given a string of tuples of the form field=value, extract the value for a field
|
|
|
|
# In : $string, $field
|
|
|
|
# Out: $value
|
|
|
|
value_extract() {
|
|
|
|
set -- $string
|
|
|
|
for x in "$@"; do
|
|
|
|
case "$x" in
|
|
|
|
$field=*)
|
|
|
|
value="${x#$field=}"
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2018-11-01 17:12:22 -05:00
|
|
|
program_console_speed()
|
|
|
|
{
|
|
|
|
speed=$(cat /proc/cmdline | grep -Eo 'console=ttyS[0-9]+,[0-9]+' | cut -d "," -f2)
|
|
|
|
if [ -z "$speed" ]; then
|
|
|
|
CONSOLE_SPEED=9600
|
|
|
|
else
|
|
|
|
CONSOLE_SPEED=$speed
|
|
|
|
fi
|
|
|
|
|
2021-08-26 09:14:34 -05:00
|
|
|
# Set correct baud rate in getty service
|
|
|
|
# First boot will find keep-baud argument with multiple baud rates as per Debian convention
|
|
|
|
# Subsequent boots may have new baud rate without finding keep-baud argument
|
|
|
|
grep agetty /lib/systemd/system/serial-getty@.service |grep keep-baud
|
|
|
|
if [ $? = 0 ]; then
|
|
|
|
sed -i "s|\-\-keep\-baud .* %I| $CONSOLE_SPEED %I|g" /lib/systemd/system/serial-getty@.service
|
|
|
|
else
|
|
|
|
sed -i "s|u' .* %I|u' $CONSOLE_SPEED %I|g" /lib/systemd/system/serial-getty@.service
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Reload systemd config
|
2018-11-01 17:12:22 -05:00
|
|
|
systemctl daemon-reload
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:27:07 -05:00
|
|
|
|
2018-06-28 07:29:14 -05:00
|
|
|
#### Begin Main Body ####
|
|
|
|
|
2019-09-09 16:18:23 -05:00
|
|
|
logger "SONiC version ${SONIC_VERSION} starting up..."
|
|
|
|
|
2017-08-27 22:13:38 -05:00
|
|
|
# If the machine.conf is absent, it indicates that the unit booted
|
|
|
|
# into SONiC from another NOS. Extract the machine.conf from ONIE.
|
2020-10-04 01:00:39 -05:00
|
|
|
grub_installation_needed=""
|
2017-08-27 22:13:38 -05:00
|
|
|
if [ ! -e /host/machine.conf ]; then
|
|
|
|
onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//')
|
|
|
|
mkdir -p /mnt/onie-boot
|
|
|
|
mount $onie_dev /mnt/onie-boot
|
|
|
|
onie_grub_cfg=/mnt/onie-boot/onie/grub/grub-machine.cfg
|
2020-09-08 14:29:02 -05:00
|
|
|
|
2017-08-27 22:13:38 -05:00
|
|
|
if [ ! -e $onie_grub_cfg ]; then
|
2018-03-08 18:42:41 -06:00
|
|
|
log_migration "$onie_grub_cfg not found"
|
2017-08-27 22:13:38 -05:00
|
|
|
else
|
|
|
|
. ./$onie_grub_cfg
|
|
|
|
grep = $onie_grub_cfg | sed -e 's/onie_//' -e 's/=.*$//' | while read var ; do
|
|
|
|
eval val='$'onie_$var
|
|
|
|
echo "onie_${var}=${val}" >> /host/machine.conf
|
|
|
|
done
|
2020-10-04 01:00:39 -05:00
|
|
|
grub_installation_needed="TRUE"
|
2017-08-27 22:13:38 -05:00
|
|
|
fi
|
|
|
|
|
2022-03-24 13:14:37 -05:00
|
|
|
migrate_nos_configuration
|
2017-08-27 22:13:38 -05:00
|
|
|
umount /mnt/onie-boot
|
|
|
|
fi
|
|
|
|
|
2017-02-27 15:08:41 -06:00
|
|
|
. /host/machine.conf
|
|
|
|
|
2018-11-01 17:12:22 -05:00
|
|
|
program_console_speed
|
|
|
|
|
2018-06-28 07:29:14 -05:00
|
|
|
if [ -f $FIRST_BOOT_FILE ]; then
|
2018-06-04 23:06:58 -05:00
|
|
|
|
2018-06-28 07:29:14 -05:00
|
|
|
echo "First boot detected. Performing first boot tasks..."
|
2018-06-04 23:06:58 -05:00
|
|
|
|
2017-03-02 12:10:40 -06:00
|
|
|
if [ -n "$aboot_platform" ]; then
|
2017-03-01 19:05:13 -06:00
|
|
|
platform=$aboot_platform
|
2017-03-02 12:10:40 -06:00
|
|
|
elif [ -n "$onie_platform" ]; then
|
2017-03-01 19:05:13 -06:00
|
|
|
platform=$onie_platform
|
|
|
|
else
|
2018-06-28 07:29:14 -05:00
|
|
|
echo "Unknown SONiC platform"
|
2017-09-17 13:41:30 -05:00
|
|
|
firsttime_exit
|
2017-02-27 15:08:41 -06:00
|
|
|
fi
|
2017-03-01 19:05:13 -06:00
|
|
|
|
2017-06-21 13:02:25 -05:00
|
|
|
# Try to take old configuration saved during installation
|
2018-03-09 19:17:08 -06:00
|
|
|
# and create a flag in /tmp/ to let updategraph service know
|
|
|
|
if [ -d /host/old_config ]; then
|
|
|
|
mv -f /host/old_config /etc/sonic/
|
2018-07-31 14:50:54 -05:00
|
|
|
rm -rf /etc/sonic/old_config/old_config
|
2018-03-09 19:17:08 -06:00
|
|
|
touch /tmp/pending_config_migration
|
2017-06-21 13:02:25 -05:00
|
|
|
elif [ -f /host/minigraph.xml ]; then
|
2018-03-09 19:17:08 -06:00
|
|
|
mkdir -p /etc/sonic/old_config
|
|
|
|
mv /host/minigraph.xml /etc/sonic/old_config/
|
2019-11-06 22:18:31 -06:00
|
|
|
[ -f /host/acl.json ] && mv /host/acl.json /etc/sonic/old_config/
|
2021-07-14 19:56:35 -05:00
|
|
|
[ -f /host/port_config.json ] && mv /host/port_config.json /etc/sonic/old_config/
|
2019-11-06 22:18:31 -06:00
|
|
|
[ -f /host/snmp.yml ] && mv /host/snmp.yml /etc/sonic/old_config/
|
2018-03-09 19:17:08 -06:00
|
|
|
touch /tmp/pending_config_migration
|
2018-03-08 18:42:41 -06:00
|
|
|
elif [ -n "$migration" ] && [ -f /host/migration/minigraph.xml ]; then
|
2018-03-09 19:17:08 -06:00
|
|
|
mkdir -p /etc/sonic/old_config
|
|
|
|
mv /host/migration/minigraph.xml /etc/sonic/old_config/
|
2018-05-16 12:04:17 -05:00
|
|
|
[ -f /host/migration/acl.json ] && mv /host/migration/acl.json /etc/sonic/old_config/
|
2021-07-14 19:56:35 -05:00
|
|
|
[ -f /host/migration/port_config.json ] && mv /host/migration/port_config.json /etc/sonic/old_config/
|
2018-05-16 12:04:17 -05:00
|
|
|
[ -f /host/migration/snmp.yml ] && mv /host/migration/snmp.yml /etc/sonic/old_config/
|
2018-03-09 19:17:08 -06:00
|
|
|
touch /tmp/pending_config_migration
|
2018-03-23 17:16:54 -05:00
|
|
|
[ -f /etc/sonic/updategraph.conf ] && sed -i -e "s/enabled=false/enabled=true/g" /etc/sonic/updategraph.conf
|
2017-04-26 03:41:18 -05:00
|
|
|
else
|
2018-03-09 19:17:08 -06:00
|
|
|
touch /tmp/pending_config_initialization
|
2018-01-29 10:11:05 -06:00
|
|
|
fi
|
|
|
|
|
2019-09-17 18:51:46 -05:00
|
|
|
# Notify firstboot to Platform, to use it for reboot-cause
|
|
|
|
touch /tmp/notify_firstboot_to_platform
|
|
|
|
|
2020-02-18 02:02:33 -06:00
|
|
|
# Create /host/reboot-cause/platform/ directory
|
|
|
|
# can be used to track last reboot reason by some platforms
|
|
|
|
if [ ! -d /host/reboot-cause/platform ]; then
|
|
|
|
mkdir -p /host/reboot-cause/platform
|
|
|
|
fi
|
|
|
|
|
2018-06-28 07:29:14 -05:00
|
|
|
if [ -d /host/image-$SONIC_VERSION/platform/$platform ]; then
|
2022-11-16 21:20:42 -06:00
|
|
|
if [ -f /host/image-$SONIC_VERSION/platform/common/Packages.gz ]; then
|
|
|
|
# Use only the trivial repo and apt to support lazy package dependencies
|
|
|
|
mv /etc/apt/sources.list /etc/apt/sources.list.rc-local
|
|
|
|
echo "deb [trusted=yes] file:///host/image-$SONIC_VERSION/platform/common /" > /etc/apt/sources.list.d/sonic_debian_extension.list
|
|
|
|
LANG=C DEBIAN_FRONTEND=noninteractive apt-get update
|
2023-01-11 10:54:24 -06:00
|
|
|
LANG=C DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Path=$PATH:/usr/local/bin -y install /host/image-$SONIC_VERSION/platform/$platform/*.deb
|
2022-11-16 21:20:42 -06:00
|
|
|
# Cleanup
|
|
|
|
rm -f /etc/apt/sources.list.d/sonic_debian_extension.list
|
|
|
|
rm -f /var/lib/apt/lists/_host_image-${SONIC_VERSION}_platform_common_Packages.lz4
|
|
|
|
# This is first boot so there should be no package lists or indices to restore, just the sources
|
|
|
|
mv /etc/apt/sources.list.rc-local /etc/apt/sources.list
|
|
|
|
else
|
|
|
|
dpkg -i /host/image-$SONIC_VERSION/platform/$platform/*.deb
|
|
|
|
fi
|
2017-03-01 19:05:13 -06:00
|
|
|
fi
|
|
|
|
|
2019-10-02 15:58:34 -05:00
|
|
|
sync
|
|
|
|
|
2017-09-17 13:41:30 -05:00
|
|
|
# If the unit booted into SONiC from another NOS's grub,
|
|
|
|
# we now install a grub for SONiC.
|
2020-10-04 01:00:39 -05:00
|
|
|
if [ -n "$onie_platform" ] && [ -n "$grub_installation_needed" ]; then
|
2017-09-17 13:41:30 -05:00
|
|
|
|
2022-07-12 17:00:57 -05:00
|
|
|
grub_bin=$(ls /host/image-$SONIC_VERSION/platform/grub/grub*.deb 2> /dev/null)
|
2017-09-17 13:41:30 -05:00
|
|
|
if [ -z "$grub_bin" ]; then
|
2018-03-08 18:42:41 -06:00
|
|
|
log_migration "Unable to locate grub package !"
|
2017-09-17 13:41:30 -05:00
|
|
|
firsttime_exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
dpkg -i $grub_bin > /dev/null 2>&1
|
|
|
|
if [ $? != 0 ]; then
|
2018-03-08 18:42:41 -06:00
|
|
|
log_migration "Unable to install grub package !"
|
2017-09-17 13:41:30 -05:00
|
|
|
firsttime_exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Determine the block device to install grub
|
|
|
|
sonic_dev=$(blkid | grep SONiC-OS | head -n 1 | awk '{print $1}' | sed -e 's/[0-9]:.*$//')
|
|
|
|
if [ -z "$sonic_dev" ]; then
|
2018-03-08 18:42:41 -06:00
|
|
|
log_migration "Unable to determine sonic partition !"
|
2017-09-17 13:41:30 -05:00
|
|
|
firsttime_exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
grub-install --boot-directory=/host --recheck $sonic_dev 2>/dev/null
|
|
|
|
if [ $? != 0 ]; then
|
2018-03-08 18:42:41 -06:00
|
|
|
log_migration "grub install failed !"
|
2017-09-17 13:41:30 -05:00
|
|
|
firsttime_exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# The SONiC "raw" build mode has already generated a proto grub.cfg
|
|
|
|
# as part of the migration. Platform specific constants need to be
|
|
|
|
# retrieved from installer.conf (if present) and assigned.
|
|
|
|
. /usr/share/sonic/device/$platform/installer.conf
|
|
|
|
|
|
|
|
if [ ! -z "$CONSOLE_PORT" ]; then
|
|
|
|
field="\-\-port"
|
|
|
|
string=$(grep $field /host/grub.cfg)
|
|
|
|
value_extract $string $field
|
|
|
|
console_port=$value
|
|
|
|
if [ ! -z "$console_port" ] && [ "$console_port" != "$CONSOLE_PORT" ]; then
|
|
|
|
sed -i -e "s/\-\-port=$console_port/\-\-port=$CONSOLE_PORT/g" /host/grub.cfg
|
|
|
|
fi
|
2018-03-08 18:42:41 -06:00
|
|
|
log_migration "grub.cfg console port=$console_port & installer.conf CONSOLE_PORT=$CONSOLE_PORT"
|
2017-09-17 13:41:30 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z "$CONSOLE_DEV" ]; then
|
|
|
|
field="console"
|
|
|
|
string=$(grep $field /host/grub.cfg)
|
|
|
|
value_extract $string $field
|
|
|
|
console_dev_name=$(echo $value | sed -e "s/^.*=//" -e "s/,.*//")
|
|
|
|
console_dev="${console_dev_name#ttyS}"
|
|
|
|
if [ "$console_dev" != "$CONSOLE_DEV" ]; then
|
|
|
|
sed -i -e "s/console=ttyS$console_dev/console=ttyS$CONSOLE_DEV/g" /host/grub.cfg
|
|
|
|
fi
|
2018-03-08 18:42:41 -06:00
|
|
|
log_migration "grub.cfg console dev=$console_dev & installer.conf CONSOLE_DEV=$CONSOLE_DEV"
|
2017-09-17 13:41:30 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z "$VAR_LOG_SIZE" ]; then
|
|
|
|
field="var_log_size"
|
|
|
|
string=$(grep $field /host/grub.cfg)
|
|
|
|
value_extract $string $field
|
|
|
|
var_log_size=$value
|
|
|
|
if [ ! -z "$var_log_size" ] && [ "$var_log_size" != "$VAR_LOG_SIZE" ]; then
|
|
|
|
sed -i -e "s/var_log_size=$var_log_size/var_log_size=$VAR_LOG_SIZE/g" /host/grub.cfg
|
|
|
|
fi
|
2018-03-08 18:42:41 -06:00
|
|
|
log_migration "grub.cfg var_log_size=$var_log_size & installer.conf VAR_LOG_SIZE=$VAR_LOG_SIZE"
|
2017-09-17 13:41:30 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Set the root based on the label
|
|
|
|
sonic_root=$(blkid | grep SONiC-OS | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//')
|
|
|
|
sonic_root=$(echo "$sonic_root" | sed 's/\//\\\//g')
|
|
|
|
sed -i -e "s/%%SONIC_ROOT%%/$sonic_root/g" /host/grub.cfg
|
|
|
|
|
|
|
|
# Add the Diag and ONIE entries
|
|
|
|
mount $onie_dev /mnt/onie-boot
|
|
|
|
. /mnt/onie-boot/onie/grub.d/50_onie_grub >> /host/grub.cfg
|
|
|
|
umount /mnt/onie-boot
|
|
|
|
|
|
|
|
# Initialize the SONiC's grub config
|
|
|
|
mv /host/grub.cfg /host/grub/grub.cfg
|
|
|
|
fi
|
|
|
|
|
2020-01-22 12:02:28 -06:00
|
|
|
# Create dir where following scripts put their output files
|
|
|
|
mkdir -p /var/platform
|
|
|
|
|
2020-12-10 03:32:37 -06:00
|
|
|
# Kdump tools configuration
|
2022-01-20 20:27:10 -06:00
|
|
|
[ -f /etc/default/kdump-tools ] && sed -i -e "s/__PLATFORM__/$platform/g" /etc/default/kdump-tools
|
2020-12-10 03:32:37 -06:00
|
|
|
|
2018-06-28 07:29:14 -05:00
|
|
|
firsttime_exit
|
2017-02-27 15:08:41 -06:00
|
|
|
fi
|
|
|
|
|
2020-04-30 02:33:20 -05:00
|
|
|
# Copy the fsck log into syslog
|
|
|
|
if [ -f /var/log/fsck.log.gz ]; then
|
|
|
|
gunzip -d -c /var/log/fsck.log.gz | logger -t "FSCK"
|
|
|
|
rm -f /var/log/fsck.log.gz
|
|
|
|
fi
|
|
|
|
|
2017-02-27 15:08:41 -06:00
|
|
|
exit 0
|