2019-03-22 04:49:35 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Generate supervisord config file and the start.sh scripts
|
|
|
|
mkdir -p /etc/supervisor/conf.d/
|
|
|
|
|
2020-07-28 02:23:21 -05:00
|
|
|
SENSORS_CONF_FILE="/usr/share/sonic/platform/sensors.conf"
|
|
|
|
FANCONTROL_CONF_FILE="/usr/share/sonic/platform/fancontrol"
|
2020-05-15 20:00:47 -05:00
|
|
|
|
|
|
|
HAVE_SENSORS_CONF=0
|
|
|
|
HAVE_FANCONTROL_CONF=0
|
|
|
|
|
2021-05-06 17:01:35 -05:00
|
|
|
{% if CONFIGURED_PLATFORM == "mellanox" %}
|
|
|
|
SENSORS_CONF_PATH_GETTER="/usr/share/sonic/platform/get_sensors_conf_path"
|
|
|
|
if [ -e $SENSORS_CONF_PATH_GETTER ]; then
|
|
|
|
SENSORS_CONF_FILE=$($SENSORS_CONF_PATH_GETTER 2>&1)
|
|
|
|
fi
|
|
|
|
{% endif %}
|
|
|
|
|
2020-07-28 02:23:21 -05:00
|
|
|
if [ -e $SENSORS_CONF_FILE ]; then
|
2020-05-15 20:00:47 -05:00
|
|
|
HAVE_SENSORS_CONF=1
|
|
|
|
fi
|
|
|
|
|
2020-07-28 02:23:21 -05:00
|
|
|
if [ -e $FANCONTROL_CONF_FILE ]; then
|
2020-05-15 20:00:47 -05:00
|
|
|
HAVE_FANCONTROL_CONF=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
confvar="{\"HAVE_SENSORS_CONF\":$HAVE_SENSORS_CONF, \"HAVE_FANCONTROL_CONF\":$HAVE_FANCONTROL_CONF}"
|
|
|
|
|
|
|
|
if [ -e /usr/share/sonic/platform/pmon_daemon_control.json ];
|
2019-03-22 04:49:35 -05:00
|
|
|
then
|
2020-05-15 20:00:47 -05:00
|
|
|
sonic-cfggen -j /usr/share/sonic/platform/pmon_daemon_control.json -a "$confvar" -t /usr/share/sonic/templates/docker-pmon.supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
|
2019-03-22 04:49:35 -05:00
|
|
|
else
|
2020-05-15 20:00:47 -05:00
|
|
|
sonic-cfggen -a "$confvar" -t /usr/share/sonic/templates/docker-pmon.supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
|
2019-03-22 04:49:35 -05:00
|
|
|
fi
|
|
|
|
|
2020-07-28 02:23:21 -05:00
|
|
|
# If this platform has an lm-sensors config file, copy it to its proper place
|
|
|
|
if [ $HAVE_SENSORS_CONF -eq 1 ]; then
|
2020-05-15 20:00:47 -05:00
|
|
|
mkdir -p /etc/sensors.d
|
2021-05-06 17:01:35 -05:00
|
|
|
/bin/cp -f $SENSORS_CONF_FILE /etc/sensors.d/sensors.conf
|
2020-05-15 20:00:47 -05:00
|
|
|
fi
|
|
|
|
|
2020-07-28 02:23:21 -05:00
|
|
|
# If this platform has a fancontrol config file, copy it to its proper place
|
|
|
|
if [ $HAVE_FANCONTROL_CONF -eq 1 ]; then
|
2020-05-15 20:00:47 -05:00
|
|
|
# Remove stale pid file if it exists
|
|
|
|
rm -f /var/run/fancontrol.pid
|
2019-03-22 04:49:35 -05:00
|
|
|
|
2020-07-28 02:23:21 -05:00
|
|
|
/bin/cp -f $FANCONTROL_CONF_FILE /etc/
|
2020-05-15 20:00:47 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
exec /usr/bin/supervisord
|