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.
Merge pull request sonic-net#92 from DennisChiuEC/202311.X
Check and install sonic-platform package when pmon container is run very time
- Loading branch information
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 |