This repository has been archived on 2025-03-20. You can view files and clone it, but cannot push or open issues or pull requests.
sonic-buildimage/files/image_config/platform/rc.local

50 lines
1.3 KiB
Bash
Executable File

#!/bin/sh -e
#
# 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.
. /host/machine.conf
echo "install platform dependent packages at the first boot time"
sonic_version=$(cat /etc/sonic/sonic_version.yml | grep build_version | cut -f2 -d" ")
if [ -f /host/image-$sonic_version/platform/firsttime ]; then
if [ -n "$aboot_platform" ]; then
platform=$aboot_platform
elif [ -n "$onie_platform" ]; then
platform=$onie_platform
else
echo "Unknown sonic platform"
rm /host/image-$sonic_version/platform/firsttime
exit 0
fi
# Try to take old configuration saved during installation
if [ -d /host/old_config ]; then
rm -f /host/old_config/sonic_version.yml
mv -f /host/old_config/* /etc/sonic/
elif [ -f /host/minigraph.xml ]; then
mv /host/minigraph.xml /etc/sonic/
else
cp /usr/share/sonic/device/$platform/minigraph.xml /etc/sonic/
fi
if [ -d /host/image-$sonic_version/platform/$platform ]; then
dpkg -i /host/image-$sonic_version/platform/$platform/*.deb
fi
rm /host/image-$sonic_version/platform/firsttime
fi
exit 0