Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions dockers/docker-platform-monitor/docker_init.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

echo "enter pmon docker_init.j2"

# Generate supervisord config file and the start.sh scripts
mkdir -p /etc/supervisor/conf.d/

Expand Down Expand Up @@ -30,6 +32,8 @@ if [ "${RUNTIME_OWNER}" == "" ]; then
RUNTIME_OWNER="kube"
fi

echo "confirm the existing for container_startup.py"

CTR_SCRIPT="/usr/share/sonic/scripts/container_startup.py"
if test -f ${CTR_SCRIPT}
then
Expand All @@ -48,6 +52,8 @@ if [ -e /usr/share/sonic/platform/platform_wait ]; then
fi
fi

echo "confirm the installation of sonic-platform package python2 version"

# If the Python 2 sonic-platform package is not installed, try to install it
python2 -c "import sonic_platform" > /dev/null 2>&1 || pip2 show sonic-platform > /dev/null 2>&1
if [ $? -ne 0 ]; then
Expand All @@ -65,6 +71,8 @@ if [ $? -ne 0 ]; then
fi
fi

echo "confirm the installation of sonic-platform package python3 version"

# 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
Expand All @@ -87,6 +95,7 @@ fi

{% if CONFIGURED_PLATFORM == "mellanox" %}

echo "dynamic sensors.conf setup"
# Dynamic sensors.conf setup: create a symlink from SONiC platform directory sensors.conf -> hw-management sensors.conf
# This allows pmon container to use the latest sensor configuration from hw-management
HW_MGMT_SENSORS_CONF="/var/run/hw-management/config/lm_sensors_config"
Expand All @@ -112,6 +121,8 @@ fi
mount -t debugfs none /sys/kernel/debug
{% endif %}

echo "confirm the existing for sensors.conf"

if [ -e $SENSORS_CONF_FILE ]; then
HAVE_SENSORS_CONF=1
mkdir -p /etc/sensors.d
Expand All @@ -126,12 +137,16 @@ if [ -e $SENSORS_CONF_FILE ]; then
/bin/cp -f $SENSORS_CONF_FILE /etc/sensors.d/sensors.conf
fi

echo "confirm the existing for fancontrol.conf"

if [ -e $FANCONTROL_CONF_FILE ]; then
HAVE_FANCONTROL_CONF=1
rm -f /var/run/fancontrol.pid
/bin/cp -f $FANCONTROL_CONF_FILE /etc/
fi

echo "confirm the existing for platform_env.conf"

if [ -e $PLATFORM_ENV_CONF_FILE ]; then
source $PLATFORM_ENV_CONF_FILE
fi
Expand All @@ -142,11 +157,15 @@ fi

confvar="{\"HAVE_SENSORS_CONF\":$HAVE_SENSORS_CONF, \"HAVE_FANCONTROL_CONF\":$HAVE_FANCONTROL_CONF, \"API_VERSION\":$SONIC_PLATFORM_API_PYTHON_VERSION, \"IS_MODULAR_CHASSIS\":$IS_MODULAR_CHASSIS}"

echo "generate supervisord config file"

if [ -e $PMON_DAEMON_CONTROL_FILE ];
then
sonic-cfggen -d -j $PMON_DAEMON_CONTROL_FILE -a "$confvar" -t $SUPERVISOR_CONF_TEMPLATE > $SUPERVISOR_CONF_FILE
else
sonic-cfggen -d -a "$confvar" -t $SUPERVISOR_CONF_TEMPLATE > $SUPERVISOR_CONF_FILE
fi

echo "start supervisord"

exec /usr/local/bin/supervisord