2020-05-15 20:00:47 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
declare -r EXIT_SUCCESS="0"
|
|
|
|
|
|
|
|
mkdir -p /var/sonic
|
|
|
|
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status
|
|
|
|
|
|
|
|
# If this platform has synchronization script, run it
|
|
|
|
if [ -e /usr/share/sonic/platform/platform_wait ]; then
|
|
|
|
/usr/share/sonic/platform/platform_wait
|
|
|
|
EXIT_CODE="$?"
|
|
|
|
if [ "${EXIT_CODE}" != "${EXIT_SUCCESS}" ]; then
|
|
|
|
supervisorctl shutdown
|
|
|
|
exit "${EXIT_CODE}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2020-10-30 11:43:14 -05:00
|
|
|
# If the Python 2 sonic-platform package is not installed, try to install it
|
2020-11-01 03:48:07 -06:00
|
|
|
python2 -c "import sonic_platform" > /dev/null 2>&1 || pip2 show sonic-platform > /dev/null 2>&1
|
2020-05-15 20:00:47 -05:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py2-none-any.whl"
|
|
|
|
echo "sonic-platform package not installed, attempting to install..."
|
|
|
|
if [ -e ${SONIC_PLATFORM_WHEEL} ]; then
|
2020-10-30 11:43:14 -05:00
|
|
|
pip2 install ${SONIC_PLATFORM_WHEEL}
|
2020-05-15 20:00:47 -05:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Successfully installed ${SONIC_PLATFORM_WHEEL}"
|
|
|
|
else
|
|
|
|
echo "Error: Failed to install ${SONIC_PLATFORM_WHEEL}"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Error: Unable to locate ${SONIC_PLATFORM_WHEEL}"
|
|
|
|
fi
|
|
|
|
fi
|
2020-09-29 15:57:54 -05:00
|
|
|
|
2020-10-30 11:43:14 -05:00
|
|
|
# If the Python 3 sonic-platform package is not installed, try to install it
|
2020-11-01 03:48:07 -06:00
|
|
|
python3 -c "import sonic_platform" > /dev/null 2>&1 || pip3 show sonic-platform > /dev/null 2>&1
|
2020-09-29 15:57:54 -05:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py3-none-any.whl"
|
|
|
|
echo "sonic-platform package not installed, attempting to install..."
|
|
|
|
if [ -e ${SONIC_PLATFORM_WHEEL} ]; then
|
2020-10-30 11:43:14 -05:00
|
|
|
pip3 install ${SONIC_PLATFORM_WHEEL}
|
2020-09-29 15:57:54 -05:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Successfully installed ${SONIC_PLATFORM_WHEEL}"
|
|
|
|
else
|
|
|
|
echo "Error: Failed to install ${SONIC_PLATFORM_WHEEL}"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Error: Unable to locate ${SONIC_PLATFORM_WHEEL}"
|
|
|
|
fi
|
|
|
|
fi
|