2017-05-08 17:43:31 -05:00
|
|
|
#!/usr/bin/env bash
|
2016-07-26 14:01:58 -05:00
|
|
|
|
2017-05-08 17:43:31 -05:00
|
|
|
mkdir -p /etc/swss/config.d/
|
2021-06-09 12:53:47 -05:00
|
|
|
mkdir -p /etc/supervisor/
|
|
|
|
mkdir -p /etc/supervisor/conf.d/
|
2017-04-21 16:28:30 -05:00
|
|
|
|
2020-08-17 17:47:52 -05:00
|
|
|
CFGGEN_PARAMS=" \
|
|
|
|
-d \
|
2022-02-09 05:29:18 -06:00
|
|
|
{% if ENABLE_ASAN == "y" %}
|
|
|
|
-a "{\"ENABLE_ASAN\":\"{{ENABLE_ASAN}}\"}" \
|
|
|
|
{% endif %}
|
2020-08-17 17:47:52 -05:00
|
|
|
-y /etc/sonic/constants.yml \
|
|
|
|
-t /usr/share/sonic/templates/switch.json.j2,/etc/swss/config.d/switch.json \
|
2022-01-31 07:57:30 -06:00
|
|
|
-t /usr/share/sonic/templates/vxlan.json.j2,/etc/swss/config.d/vxlan.json \
|
2020-08-17 17:47:52 -05:00
|
|
|
-t /usr/share/sonic/templates/ipinip.json.j2,/etc/swss/config.d/ipinip.json \
|
|
|
|
-t /usr/share/sonic/templates/ports.json.j2,/etc/swss/config.d/ports.json \
|
|
|
|
-t /usr/share/sonic/templates/vlan_vars.j2 \
|
2020-10-05 10:48:13 -05:00
|
|
|
-t /usr/share/sonic/templates/ndppd.conf.j2,/etc/ndppd.conf \
|
2021-06-09 12:53:47 -05:00
|
|
|
-t /usr/share/sonic/templates/critical_processes.j2,/etc/supervisor/critical_processes \
|
|
|
|
-t /usr/share/sonic/templates/supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf
|
2022-03-02 18:23:56 -06:00
|
|
|
-t /usr/share/sonic/templates/wait_for_link.sh.j2,/usr/bin/wait_for_link.sh \
|
2020-08-17 17:47:52 -05:00
|
|
|
"
|
|
|
|
VLAN=$(sonic-cfggen $CFGGEN_PARAMS)
|
2022-08-09 18:19:59 -05:00
|
|
|
SUBTYPE=$(sonic-cfggen -d -v "DEVICE_METADATA['localhost']['subtype']")
|
2022-07-26 18:50:16 -05:00
|
|
|
SWITCH_TYPE=${SWITCH_TYPE:-`sonic-cfggen -d -v "DEVICE_METADATA['localhost']['switch_type']"`}
|
2022-03-02 18:23:56 -06:00
|
|
|
chmod +x /usr/bin/wait_for_link.sh
|
|
|
|
|
2021-12-17 10:43:25 -06:00
|
|
|
# Executed platform specific initialization tasks.
|
|
|
|
if [ -x /usr/share/sonic/platform/platform-init ]; then
|
|
|
|
/usr/share/sonic/platform/platform-init
|
|
|
|
fi
|
|
|
|
|
2018-09-24 16:56:37 -05:00
|
|
|
# Executed HWSKU specific initialization tasks.
|
|
|
|
if [ -x /usr/share/sonic/hwsku/hwsku-init ]; then
|
|
|
|
/usr/share/sonic/hwsku/hwsku-init
|
|
|
|
fi
|
|
|
|
|
2022-07-26 18:50:16 -05:00
|
|
|
# Start arp update when VLAN exists or switch type as chassis packet for backend port channel interfaces
|
|
|
|
if [[ "$VLAN" != "" ]] || [[ "$SWITCH_TYPE" == "chassis-packet" ]]; then
|
2020-09-17 20:33:10 -05:00
|
|
|
cp /usr/share/sonic/templates/arp_update.conf /etc/supervisor/conf.d/
|
2022-07-26 18:50:16 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$VLAN" != "" ]; then
|
2020-10-05 10:48:13 -05:00
|
|
|
cp /usr/share/sonic/templates/ndppd.conf /etc/supervisor/conf.d/
|
2017-05-15 19:06:19 -05:00
|
|
|
fi
|
2020-05-15 19:09:16 -05:00
|
|
|
|
2022-08-09 18:19:59 -05:00
|
|
|
if [ "$SUBTYPE" == "DualToR" ]; then
|
|
|
|
cp /usr/share/sonic/templates/tunnel_packet_handler.conf /etc/supervisor/conf.d/
|
|
|
|
fi
|
|
|
|
|
2022-11-26 22:27:30 -06:00
|
|
|
IS_SUPERVISOR=/etc/sonic/chassisdb.conf
|
2022-04-25 15:09:42 -05:00
|
|
|
USE_PCI_ID_IN_CHASSIS_STATE_DB=/usr/share/sonic/platform/use_pci_id_chassis
|
|
|
|
ASIC_ID="asic$NAMESPACE_ID"
|
2022-11-26 22:27:30 -06:00
|
|
|
if [ -f "$IS_SUPERVISOR" ]; then
|
|
|
|
if [ -f "$USE_PCI_ID_IN_CHASSIS_STATE_DB" ]; then
|
|
|
|
while true; do
|
2022-12-08 13:36:45 -06:00
|
|
|
PCI_ID=$(sonic-db-cli -s CHASSIS_STATE_DB HGET "CHASSIS_FABRIC_ASIC_TABLE|$ASIC_ID" asic_pci_address)
|
2022-11-26 22:27:30 -06:00
|
|
|
if [ -z "$PCI_ID" ]; then
|
|
|
|
sleep 3
|
|
|
|
else
|
|
|
|
# Update asic_id in CONFIG_DB, which is used by orchagent and fed to syncd
|
|
|
|
if [[ $PCI_ID == ????:??:??.? ]]; then
|
|
|
|
sonic-db-cli CONFIG_DB HSET 'DEVICE_METADATA|localhost' 'asic_id' ${PCI_ID#*:}
|
|
|
|
break
|
|
|
|
fi
|
2022-04-25 15:09:42 -05:00
|
|
|
fi
|
2022-11-26 22:27:30 -06:00
|
|
|
done
|
|
|
|
fi
|
2022-04-25 15:09:42 -05:00
|
|
|
fi
|
2020-11-22 23:18:44 -06:00
|
|
|
exec /usr/local/bin/supervisord
|