forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check and install sonic-platform package when pmon container is run e…
…very time Originally, the sonic-platform package will only be installed during the creation of pmon. If the switch is powered off during the creation and initialization of pmon, the process to install sonic-platform package will be terminated and the sonic-platform package will not be reinstalled when pmon container is restarted. The sonic-platform package is the base module in pmon container. The daemon can not be run correctlly if the sonic-platform package is not installed. Modification: - Remove the python version v2 and v3 check when generate supervisord.conf in pmon - Installed the sonic-platform package if it is not existed when pmon container is run. - Check the METADATA if the sonic_platform package has been installed. According to the description in the following link: https://packaging.python.org/en/latest/specifications/recording-installed-packages/#the-metadata-file The METADATA should be created after a package is installed and its size should not be zero. - Let the related daemons be started after the sonic-platform package installation check is done.
- Loading branch information
1 parent
78466f5
commit b648f41
Showing
4 changed files
with
64 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py3-none-any.whl" | ||
# If the Python 3 sonic-platform package is not installed, try to install it | ||
python3 -c "import sonic_platform" > /dev/null 2>&1 || pip3 show sonic-platform > /dev/null 2>&1 | ||
if [ $? -ne 0 ]; then | ||
echo "sonic-platform package not installed, attempting to install..." | ||
if [ -e ${SONIC_PLATFORM_WHEEL} ]; then | ||
pip3 install ${SONIC_PLATFORM_WHEEL} | ||
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 | ||
else | ||
# Check that the sonic-platform package is installed correctly. | ||
# Otherwise, force re-install the sonic-platform package. | ||
python_lib_path=$(pip3 show sonic-platform | grep Location | cut -d ' ' -f 2) | ||
metadata_path="${python_lib_path}/sonic_platform-1.0.dist-info/METADATA" | ||
if [ ! -s $metadata_path ]; then | ||
echo "sonic-platform package is installed incompletely, force re-install again !!" | ||
pip3 install --force-reinstall ${SONIC_PLATFORM_WHEEL} | ||
if [ $? -eq 0 ]; then | ||
echo "Successfully re-installed ${SONIC_PLATFORM_WHEEL}" | ||
else | ||
echo "Error: Failed to re-install ${SONIC_PLATFORM_WHEEL}" | ||
fi | ||
else | ||
echo "sonic-platform package has already been installed" | ||
fi | ||
fi | ||
|
||
exit 0 |