forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_init.j2
More file actions
executable file
·171 lines (139 loc) · 5.77 KB
/
Copy pathdocker_init.j2
File metadata and controls
executable file
·171 lines (139 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/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/
SENSORS_CONF_FILE="/usr/share/sonic/platform/sensors.conf"
FANCONTROL_CONF_FILE="/usr/share/sonic/platform/fancontrol"
SUPERVISOR_CONF_TEMPLATE="/usr/share/sonic/templates/docker-pmon.supervisord.conf.j2"
SUPERVISOR_CONF_FILE="/etc/supervisor/conf.d/supervisord.conf"
MODULAR_CHASSISDB_CONF_FILE="/usr/share/sonic/platform/chassisdb.conf"
PLATFORM_ENV_CONF_FILE="/usr/share/sonic/platform/platform_env.conf"
HAVE_SENSORS_CONF=0
HAVE_FANCONTROL_CONF=0
IS_MODULAR_CHASSIS=0
# Default use python2 version
SONIC_PLATFORM_API_PYTHON_VERSION=2
if [ -e /usr/share/sonic/hwsku/pmon_daemon_control.json ];
then
PMON_DAEMON_CONTROL_FILE="/usr/share/sonic/hwsku/pmon_daemon_control.json"
else
PMON_DAEMON_CONTROL_FILE="/usr/share/sonic/platform/pmon_daemon_control.json"
fi
declare -r EXIT_SUCCESS="0"
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
${CTR_SCRIPT} -f pmon -o ${RUNTIME_OWNER} -v ${IMAGE_VERSION}
fi
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
exit "${EXIT_CODE}"
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
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
pip2 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
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
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
pip3 install ${SONIC_PLATFORM_WHEEL}
if [ $? -eq 0 ]; then
echo "Successfully installed ${SONIC_PLATFORM_WHEEL}"
SONIC_PLATFORM_API_PYTHON_VERSION=3
else
echo "Error: Failed to install ${SONIC_PLATFORM_WHEEL}"
fi
else
echo "Error: Unable to locate ${SONIC_PLATFORM_WHEEL}"
fi
else
SONIC_PLATFORM_API_PYTHON_VERSION=3
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"
SONIC_SENSORS_CONF="/usr/share/sonic/platform/sensors.conf"
if [ ! -e "$SONIC_SENSORS_CONF" ]; then
if [ -e "$HW_MGMT_SENSORS_CONF" ]; then
ln -s "$HW_MGMT_SENSORS_CONF" "$SONIC_SENSORS_CONF"
if [ ! -e "$SONIC_SENSORS_CONF" ]; then
echo "Error: Failed to create symlink for sensors.conf, 'sensors' command will print raw sensors data"
fi
else
echo "Error: sensors.conf file not found in hw-management"
fi
fi
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 %}
{% if CONFIGURED_PLATFORM == "nvidia-bluefield" %}
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
PSU_SENSORS_CONF_UPDATER="/usr/share/sonic/platform/psu_sensors_conf_updater"
if [ -e $PSU_SENSORS_CONF_UPDATER ]; then
source $PSU_SENSORS_CONF_UPDATER
update_psu_sensors_configuration $SENSORS_CONF_FILE
if [ -f /tmp/sensors.conf ]; then
SENSORS_CONF_FILE="/tmp/sensors.conf"
fi
fi
/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
if [ -e $MODULAR_CHASSISDB_CONF_FILE ] && [[ $disaggregated_chassis -ne 1 ]]; then
IS_MODULAR_CHASSIS=1
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