2017-11-30 16:59:25 -06:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
2020-09-01 15:39:10 -05:00
|
|
|
# Generate configuration
|
2017-11-30 16:59:25 -06:00
|
|
|
|
2020-09-01 15:39:10 -05:00
|
|
|
# NOTE: 'PLATFORM' and 'HWSKU' environment variables are set
|
|
|
|
# in the Dockerfile so that they persist for the life of the container
|
2018-11-21 00:32:40 -06:00
|
|
|
|
2020-09-01 15:52:29 -05:00
|
|
|
ln -sf /usr/share/sonic/device/$PLATFORM /usr/share/sonic/platform
|
2018-11-21 00:32:40 -06:00
|
|
|
ln -sf /usr/share/sonic/device/$PLATFORM/$HWSKU /usr/share/sonic/hwsku
|
|
|
|
|
2023-07-11 11:57:50 -05:00
|
|
|
SWITCH_TYPE=switch
|
2023-06-27 16:10:53 -05:00
|
|
|
PLATFORM_CONF=platform.json
|
2023-07-11 11:57:50 -05:00
|
|
|
if [[ $HWSKU == "DPU-2P" ]]; then
|
|
|
|
SWITCH_TYPE=dpu
|
|
|
|
PLATFORM_CONF=platform-dpu-2p.json
|
2023-06-27 16:10:53 -05:00
|
|
|
fi
|
|
|
|
|
2020-04-30 14:50:59 -05:00
|
|
|
pushd /usr/share/sonic/hwsku
|
|
|
|
|
|
|
|
# filter available front panel ports in lanemap.ini
|
|
|
|
[ -f lanemap.ini.orig ] || cp lanemap.ini lanemap.ini.orig
|
|
|
|
for p in $(ip link show | grep -oE "eth[0-9]+" | grep -v eth0); do
|
|
|
|
grep ^$p: lanemap.ini.orig
|
|
|
|
done > lanemap.ini
|
|
|
|
|
|
|
|
# filter available sonic front panel ports in port_config.ini
|
|
|
|
[ -f port_config.ini.orig ] || cp port_config.ini port_config.ini.orig
|
|
|
|
grep ^# port_config.ini.orig > port_config.ini
|
|
|
|
for lanes in $(awk -F ':' '{print $2}' lanemap.ini); do
|
|
|
|
grep -E "\s$lanes\s" port_config.ini.orig
|
|
|
|
done >> port_config.ini
|
|
|
|
|
|
|
|
popd
|
|
|
|
|
2017-11-30 16:59:25 -06:00
|
|
|
[ -d /etc/sonic ] || mkdir -p /etc/sonic
|
|
|
|
|
2021-01-20 14:06:08 -06:00
|
|
|
# Note: libswsscommon requires a dabase_config file in /var/run/redis/sonic-db/
|
|
|
|
# Prepare this file before any dependent application, such as sonic-cfggen
|
|
|
|
mkdir -p /var/run/redis/sonic-db
|
|
|
|
cp /etc/default/sonic-db/database_config.json /var/run/redis/sonic-db/
|
|
|
|
|
2017-11-30 16:59:25 -06:00
|
|
|
SYSTEM_MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
|
2023-07-11 11:57:50 -05:00
|
|
|
sonic-cfggen -t /usr/share/sonic/templates/init_cfg.json.j2 -a "{\"system_mac\": \"$SYSTEM_MAC_ADDRESS\", \"switch_type\": \"$SWITCH_TYPE\"}" > /etc/sonic/init_cfg.json
|
2021-10-26 20:19:58 -05:00
|
|
|
|
|
|
|
if [[ -f /usr/share/sonic/virtual_chassis/default_config.json ]]; then
|
|
|
|
sonic-cfggen -j /etc/sonic/init_cfg.json -j /usr/share/sonic/virtual_chassis/default_config.json --print-data > /tmp/init_cfg.json
|
|
|
|
mv /tmp/init_cfg.json /etc/sonic/init_cfg.json
|
|
|
|
fi
|
2017-11-30 16:59:25 -06:00
|
|
|
|
|
|
|
if [ -f /etc/sonic/config_db.json ]; then
|
2020-03-05 17:35:35 -06:00
|
|
|
sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db.json --print-data > /tmp/config_db.json
|
2017-11-30 16:59:25 -06:00
|
|
|
mv /tmp/config_db.json /etc/sonic/config_db.json
|
|
|
|
else
|
2018-01-29 10:11:05 -06:00
|
|
|
# generate and merge buffers configuration into config file
|
2023-06-27 16:10:53 -05:00
|
|
|
if [ -f /usr/share/sonic/hwsku/buffers.json.j2 ]; then
|
|
|
|
sonic-cfggen -k $HWSKU -p /usr/share/sonic/device/$PLATFORM/$PLATFORM_CONF -t /usr/share/sonic/hwsku/buffers.json.j2 > /tmp/buffers.json
|
2023-07-11 11:57:50 -05:00
|
|
|
buffers_cmd="-j /tmp/buffers.json"
|
2023-06-27 16:10:53 -05:00
|
|
|
fi
|
|
|
|
if [ -f /usr/share/sonic/hwsku/qos.json.j2 ]; then
|
|
|
|
sonic-cfggen -j /etc/sonic/init_cfg.json -t /usr/share/sonic/hwsku/qos.json.j2 > /tmp/qos.json
|
2023-07-11 11:57:50 -05:00
|
|
|
qos_cmd="-j /tmp/qos.json"
|
2023-06-27 16:10:53 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
sonic-cfggen -p /usr/share/sonic/device/$PLATFORM/$PLATFORM_CONF -k $HWSKU --print-data > /tmp/ports.json
|
2020-08-20 19:10:58 -05:00
|
|
|
# change admin_status from up to down; Test cases dependent
|
|
|
|
sed -i "s/up/down/g" /tmp/ports.json
|
2023-07-11 11:57:50 -05:00
|
|
|
sonic-cfggen -j /etc/sonic/init_cfg.json $buffers_cmd $qos_cmd -j /tmp/ports.json --print-data > /etc/sonic/config_db.json
|
2017-11-30 16:59:25 -06:00
|
|
|
fi
|
2023-07-11 11:57:50 -05:00
|
|
|
|
2020-11-23 11:31:42 -06:00
|
|
|
sonic-cfggen -t /usr/share/sonic/templates/copp_cfg.j2 > /etc/sonic/copp_cfg.json
|
2017-10-24 00:01:42 -05:00
|
|
|
|
2021-11-02 01:21:06 -05:00
|
|
|
if [ "$HWSKU" == "Mellanox-SN2700" ]; then
|
|
|
|
cp /usr/share/sonic/hwsku/sai_mlnx.profile /usr/share/sonic/hwsku/sai.profile
|
2023-07-11 11:57:50 -05:00
|
|
|
elif [ "$HWSKU" == "DPU-2P" ]; then
|
|
|
|
cp /usr/share/sonic/hwsku/sai_dpu_2p.profile /usr/share/sonic/hwsku/sai.profile
|
2021-11-02 01:21:06 -05:00
|
|
|
fi
|
|
|
|
|
2017-10-24 00:01:42 -05:00
|
|
|
mkdir -p /etc/swss/config.d/
|
|
|
|
|
|
|
|
rm -f /var/run/rsyslogd.pid
|
|
|
|
|
|
|
|
supervisorctl start rsyslogd
|
|
|
|
|
2020-07-29 16:20:31 -05:00
|
|
|
supervisord_cfg="/etc/supervisor/conf.d/supervisord.conf"
|
2020-10-14 17:15:24 -05:00
|
|
|
chassisdb_cfg_file="/usr/share/sonic/virtual_chassis/default_config.json"
|
|
|
|
chassisdb_cfg_file_default="/etc/default/sonic-db/default_chassis_cfg.json"
|
2020-07-29 16:20:31 -05:00
|
|
|
host_template="/usr/share/sonic/templates/hostname.j2"
|
|
|
|
db_cfg_file="/var/run/redis/sonic-db/database_config.json"
|
|
|
|
db_cfg_file_tmp="/var/run/redis/sonic-db/database_config.json.tmp"
|
|
|
|
|
2020-10-14 17:15:24 -05:00
|
|
|
if [ -r "$chassisdb_cfg_file" ]; then
|
|
|
|
echo $(sonic-cfggen -j $chassisdb_cfg_file -t $host_template) >> /etc/hosts
|
2020-07-29 16:20:31 -05:00
|
|
|
else
|
2020-10-14 17:15:24 -05:00
|
|
|
chassisdb_cfg_file="$chassisdb_cfg_file_default"
|
2020-07-29 16:20:31 -05:00
|
|
|
echo "10.8.1.200 redis_chassis.server" >> /etc/hosts
|
|
|
|
fi
|
|
|
|
|
2017-10-24 00:01:42 -05:00
|
|
|
supervisorctl start redis-server
|
|
|
|
|
2020-10-14 17:15:24 -05:00
|
|
|
start_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.start_chassis_db -y $chassisdb_cfg_file`
|
2020-07-29 16:20:31 -05:00
|
|
|
if [[ "$HOSTNAME" == *"supervisor"* ]] || [ "$start_chassis_db" == "1" ]; then
|
|
|
|
supervisorctl start redis-chassis
|
|
|
|
fi
|
|
|
|
|
2020-10-14 17:15:24 -05:00
|
|
|
conn_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.connect_to_chassis_db -y $chassisdb_cfg_file`
|
2020-07-29 16:20:31 -05:00
|
|
|
if [ "$start_chassis_db" != "1" ] && [ "$conn_chassis_db" != "1" ]; then
|
|
|
|
cp $db_cfg_file $db_cfg_file_tmp
|
2020-10-14 17:15:24 -05:00
|
|
|
update_chassisdb_config -j $db_cfg_file_tmp -d
|
2020-07-29 16:20:31 -05:00
|
|
|
cp $db_cfg_file_tmp $db_cfg_file
|
|
|
|
fi
|
|
|
|
|
2020-12-02 12:31:43 -06:00
|
|
|
if [ "$conn_chassis_db" == "1" ]; then
|
|
|
|
if [ -f /usr/share/sonic/virtual_chassis/coreportindexmap.ini ]; then
|
|
|
|
cp /usr/share/sonic/virtual_chassis/coreportindexmap.ini /usr/share/sonic/hwsku/
|
2021-04-01 18:24:57 -05:00
|
|
|
|
|
|
|
pushd /usr/share/sonic/hwsku
|
|
|
|
|
|
|
|
# filter available front panel ports in coreportindexmap.ini
|
|
|
|
[ -f coreportindexmap.ini.orig ] || cp coreportindexmap.ini coreportindexmap.ini.orig
|
|
|
|
for p in $(ip link show | grep -oE "eth[0-9]+" | grep -v eth0); do
|
|
|
|
grep ^$p: coreportindexmap.ini.orig
|
|
|
|
done > coreportindexmap.ini
|
|
|
|
|
|
|
|
popd
|
2020-12-02 12:31:43 -06:00
|
|
|
fi
|
|
|
|
fi
|
2020-07-29 16:20:31 -05:00
|
|
|
|
2017-11-30 16:59:25 -06:00
|
|
|
/usr/bin/configdb-load.sh
|
|
|
|
|
2021-09-15 16:02:03 -05:00
|
|
|
if [ "$HWSKU" = "brcm_gearbox_vs" ]; then
|
|
|
|
supervisorctl start gbsyncd
|
|
|
|
supervisorctl start gearsyncd
|
|
|
|
fi
|
|
|
|
|
2017-10-24 00:01:42 -05:00
|
|
|
supervisorctl start syncd
|
|
|
|
|
|
|
|
supervisorctl start portsyncd
|
|
|
|
|
2020-08-11 10:52:06 -05:00
|
|
|
supervisorctl start orchagent
|
|
|
|
|
2020-11-23 11:31:42 -06:00
|
|
|
supervisorctl start coppmgrd
|
|
|
|
|
2017-10-24 00:01:42 -05:00
|
|
|
supervisorctl start neighsyncd
|
|
|
|
|
2020-12-24 20:36:01 -06:00
|
|
|
supervisorctl start fdbsyncd
|
|
|
|
|
2017-11-03 19:13:39 -05:00
|
|
|
supervisorctl start teamsyncd
|
|
|
|
|
2017-11-13 16:38:07 -06:00
|
|
|
supervisorctl start fpmsyncd
|
|
|
|
|
2018-10-19 05:41:53 -05:00
|
|
|
supervisorctl start teammgrd
|
|
|
|
|
2019-02-01 01:28:31 -06:00
|
|
|
supervisorctl start vrfmgrd
|
|
|
|
|
2018-08-20 13:19:16 -05:00
|
|
|
supervisorctl start portmgrd
|
|
|
|
|
2017-11-30 16:59:25 -06:00
|
|
|
supervisorctl start intfmgrd
|
|
|
|
|
|
|
|
supervisorctl start vlanmgrd
|
|
|
|
|
|
|
|
supervisorctl start zebra
|
|
|
|
|
2019-05-29 18:14:48 -05:00
|
|
|
supervisorctl start staticd
|
|
|
|
|
2018-01-29 10:11:05 -06:00
|
|
|
supervisorctl start buffermgrd
|
|
|
|
|
2018-11-28 23:58:59 -06:00
|
|
|
supervisorctl start nbrmgrd
|
|
|
|
|
2019-04-23 22:38:08 -05:00
|
|
|
supervisorctl start vxlanmgrd
|
|
|
|
|
2019-10-29 20:05:55 -05:00
|
|
|
supervisorctl start sflowmgrd
|
|
|
|
|
2020-01-29 19:40:43 -06:00
|
|
|
supervisorctl start natmgrd
|
|
|
|
|
|
|
|
supervisorctl start natsyncd
|
|
|
|
|
2020-12-26 13:17:18 -06:00
|
|
|
supervisorctl start tunnelmgrd
|
|
|
|
|
2023-11-20 18:21:03 -06:00
|
|
|
supervisorctl start fabricmgrd
|
|
|
|
|
2017-10-24 00:01:42 -05:00
|
|
|
# Start arp_update when VLAN exists
|
2017-11-30 16:59:25 -06:00
|
|
|
VLAN=`sonic-cfggen -d -v 'VLAN.keys() | join(" ") if VLAN'`
|
|
|
|
if [ "$VLAN" != "" ]; then
|
|
|
|
supervisorctl start arp_update
|
|
|
|
fi
|