From 38bdecd712e2094b296af31fdea136263f74301a Mon Sep 17 00:00:00 2001 From: Alex-Dai Date: Thu, 16 Apr 2020 16:19:47 +0800 Subject: [PATCH 1/4] add clean os operation --- files/image_config/platform/rc.local | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/files/image_config/platform/rc.local b/files/image_config/platform/rc.local index 3596eb18419c..87f25b060772 100755 --- a/files/image_config/platform/rc.local +++ b/files/image_config/platform/rc.local @@ -88,8 +88,28 @@ update_mgmt_interface_macaddr() { sed -i "/eth0/ s/ATTR{address}==\"$old_mac\"/ATTR{address}==\"$new_mac\"/g" /etc/udev/rules.d/70-persistent-net.rules } +boot_action() { + #cleanos + CLEAN_OS_FILE="/etc/sonic/cleanos" + if [ -f $CLEAN_OS_FILE ]; then + echo "clean up os" + sonic_installer cleanup -y + rm -f $CLEAN_OS_FILE + fi + + decode-syseeprom --init + + #diag install + if [ ! -d /usr/local/CPU_Diag ];then + echo "Diag install" + sleep 200 + dpkg -i /home/Ali_Diag_V2.0.4.deb + fi +} + firsttime_exit() { rm -rf $FIRST_BOOT_FILE + boot_action exit 0 } @@ -354,4 +374,5 @@ if [ -f $FIRST_BOOT_FILE ]; then firsttime_exit fi +boot_action exit 0 From 94855bf2a7f9f3e96869d53e171b6d33598783be Mon Sep 17 00:00:00 2001 From: Alex-Dai Date: Thu, 16 Apr 2020 16:29:08 +0800 Subject: [PATCH 2/4] fix networking interface error when sonic bootup --- files/image_config/interfaces/interfaces.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/image_config/interfaces/interfaces.j2 b/files/image_config/interfaces/interfaces.j2 index ba6d832b6697..525cd66f4fef 100644 --- a/files/image_config/interfaces/interfaces.j2 +++ b/files/image_config/interfaces/interfaces.j2 @@ -44,7 +44,7 @@ iface eth0 {{ 'inet' if prefix | ipv4 else 'inet6' }} static {# TODO: COPP policy type rules #} {% endfor %} {% else %} -iface eth0 inet static +iface eth0 inet manual {% endif %} # {% endblock mgmt_interface %} From cae7d9f3b17db6f55e1acbb78caba15883b422a1 Mon Sep 17 00:00:00 2001 From: Alex-Dai Date: Thu, 7 May 2020 17:59:03 +0800 Subject: [PATCH 3/4] generate config_db.json when boot firsttime after os installing --- files/image_config/updategraph/updategraph | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/files/image_config/updategraph/updategraph b/files/image_config/updategraph/updategraph index 686108727b27..17079f057ef0 100755 --- a/files/image_config/updategraph/updategraph +++ b/files/image_config/updategraph/updategraph @@ -53,6 +53,9 @@ check_system_warm_boot copy_list="minigraph.xml snmp.yml acl.json config_db.json frr" if [ -f /tmp/pending_config_migration ]; then copy_config_files_and_directories $copy_list + PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform` + cp /usr/share/sonic/device/$PLATFORM/minigraph.xml /etc/sonic/minigraph.xml + sonic-cfggen -H -m /etc/sonic/minigraph.xml -j /etc/sonic/init_cfg.json --print-data > /etc/sonic/config_db.json if [ x"${WARM_BOOT}" == x"true" ]; then echo "Warm reboot detected..." elif [ "$enabled" = "true" ]; then @@ -74,7 +77,9 @@ if [ -f /tmp/pending_config_initialization ]; then if [ "$enabled" != "true" ]; then PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform` PRESET=(`head -n 1 /usr/share/sonic/device/$PLATFORM/default_sku`) - sonic-cfggen -H -k ${PRESET[0]} --preset ${PRESET[1]} > /etc/sonic/config_db.json + #sonic-cfggen -H -k ${PRESET[0]} --preset ${PRESET[1]} > /etc/sonic/config_db.json + cp /usr/share/sonic/device/$PLATFORM/minigraph.xml /etc/sonic/minigraph.xml + sonic-cfggen -H -m /etc/sonic/minigraph.xml -j /etc/sonic/init_cfg.json --print-data > /etc/sonic/config_db.json redis-cli -n $CONFIG_DB_INDEX FLUSHDB sonic-cfggen -j /etc/sonic/config_db.json --write-to-db redis-cli -n $CONFIG_DB_INDEX SET "CONFIG_DB_INITIALIZED" "1" From ebdfe500c61c8718ca5e6aac6128dd0eeb1d396f Mon Sep 17 00:00:00 2001 From: Alex-Dai Date: Mon, 11 May 2020 14:39:46 +0800 Subject: [PATCH 4/4] update diag install action --- files/image_config/platform/rc.local | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/files/image_config/platform/rc.local b/files/image_config/platform/rc.local index 87f25b060772..c96fcc07cb27 100755 --- a/files/image_config/platform/rc.local +++ b/files/image_config/platform/rc.local @@ -88,6 +88,12 @@ update_mgmt_interface_macaddr() { sed -i "/eth0/ s/ATTR{address}==\"$old_mac\"/ATTR{address}==\"$new_mac\"/g" /etc/udev/rules.d/70-persistent-net.rules } +diag_install() { + echo "Diag install start ..." + sleep 200 + dpkg -i /home/Ali_Diag_V2.0.4.deb +} + boot_action() { #cleanos CLEAN_OS_FILE="/etc/sonic/cleanos" @@ -102,8 +108,7 @@ boot_action() { #diag install if [ ! -d /usr/local/CPU_Diag ];then echo "Diag install" - sleep 200 - dpkg -i /home/Ali_Diag_V2.0.4.deb + diag_install > /var/log/diagInstallLog & fi }