ACI で APIC / スイッチを初期化するコマンドのまとめ
以前に Cisco ACI で「APIC」「Spine/Leaf」を初期化する というメモを書きました。 Cisco Community に APIC・スイッチの初期化 という記事がありますが、改めて初期化コマンドをまとめておきます。
コマンドのまとめ¶
APIC¶
APIC の初期化は 3 つのコマンドを連続して実行します。
| コマンド | 説明 |
|---|---|
acidiag touch clean |
次回、再起動時に「ポリシーデータを削除する」フラグを立てる |
acidiag touch setup |
次回、再起動時に「ネットワーク構成データとポリシーデータを削除する」フラグを立てる |
acidiag reboot |
APIC を再起動する |
スイッチ¶
スイッチの初期化には 3 つの方法があり、場合に応じていずれか 1 つを実施します。
| コマンド | 説明 |
|---|---|
acidiag touch clean |
再起動後、APIC から設定ファイルを再ダウンロードする初期化後、同一ファブリックに再参加させる場合はこのコマンドを実行する |
setup-clean-config.sh |
設定ファイルとハードウェアの状態を削除する初期化後、異なるファブリックに参加させる場合はこのコマンドを実行する |
prepare-mfg.sh |
工場出荷状態時に戻す |
APIC の初期化¶
APIC の初期化では acidiag touch clean と acidiag touch setup というコマンドを使います。 これらは「実行時に初期化している」わけでは無く、「次の再起動時に初期化を行う為のフラグを立てている」という処理をしています。 その為、これらのコマンドの実行自体はすぐに完了します。
実際の実行例は以下の通りです。 コマンド実行時は y/N を確認されますので、一度に全てのコマンドを流し込まないように注意します。
APIC# acidiag touch clean
This command will wipe out this device, Proceed? [y/N] y
APIC# acidiag touch setup
This command will reset the device configuration, Proceed? [y/N] y
APIC# acidiag reboot
This command will restart this device, Proceed? [y/N] y
スイッチの初期化¶
スイッチを初期化する方法は 3 種類、存在します。 目的・状況に応じて使い分けます。 よく分からない場合、通常は setup-clean-config.sh を利用しておけば多くの場合、問題にならないと思います。
いずれのコマンドも実行後は reload で筐体を再起動させる必要があります。
方法1:acidiag touch clean¶
「初期化したスイッチを再度、同じファブリックに参加させる為、APIC から設定を再ダウンロードさせたい」場合は acidiag touch clean を利用します。
Switch# acidiag touch clean
This command will wipe out this device, Proceed? [y/N] y
Switch# reload
This command will reload the chassis, Proceed (y/n)? [n]: y
方法2:setup-clean-config.sh¶
「初期化したスイッチを異なるファブリックに参加させる」場合は setup-clean-config.sh を利用します。 ACIでのリーフ/スパイン交換の設定 では以下のように説明されています。
これにより、新しいスイッチが以前に別のACIファブリックを使用して設定されていた場合でも、新しいスイッチにすでに存在する一部の設定が現在のファブリックと競合することが原因で発生する問題が回避されます。
Switch# setup-clean-config.sh
In progress
(snip)
In progress
Done
Switch# reload
This command will reload the chassis, Proceed (y/n)? [n]: y
方法3:prepare-mfg.sh¶
出番は少ないと思いますが「スイッチを工場出荷時に戻す」場合は prepare-mfg.sh を利用します。 このスクリプトを実行するには OS イメージのバイナリ名を指定する必要があります。 スイッチから確認するには dir /bootflash/*.bin などを実行します。
例えば aci-n9000-dk9.16.0.4c.bin という OS で工場出荷された状態に戻すには以下のように実行します。
Switch# prepare-mfg.sh aci-n9000-dk9.16.0.4c.bin
In progress
(snip)
In progress
Done
Switch# reload
This command will reload the chassis, Proceed (y/n)? [n]: y
参考¶
参考リンク¶
- ACI Fabric Switch 交換時の注意事項
- ACI: 初期化スクリプトについて
- ACIでのリーフ/スパイン交換の設定
- Factory reset APIC and nodes
- Wiping an ACI Fabric
Leaf¶
/bin/setup-clean-config.sh¶
#!/bin/bash
# Copyright (c) 2001,2002,2003,2004,2005, 2017, 2022 by cisco Systems, Inc.
. /etc/isim_include
if [ $# -gt 0 ]; then
if [ "$1" != "--keep-port-profile" -a "$1" != "-k" ]; then
echo "Usage: setup-clean-config.sh [--keep-port-profile|-k]"
exit 1
fi
fi
usr=`id -un `
if [ $usr == "root" ]; then
if [ "$1" = "" ]; then
if [ -e "/bootflash/user_config_port_profile.json" ]
then
chattr -i /bootflash/user_config_port_profile.json
fi
rm -rf /bootflash/user_config_port_profile.json
rm -f /bootflash/.user_config_port_profile.json
rm -f /bootflash/stats_pref.txt
rm -f /bootflash/.stats_pref.txt
rm -f /mnt/ifc/cfg/fwd_scale_prof.txt
rm -f /mnt/pss/lcm_port_type.config
rm -f /mnt/pss/mac_pool_dry_*.pss
rm -f /mnt/ifc/cfg/lbx_pp_share_mode.cfg
rm -f /mnt/ifc/cfg/fast_link_failover_mode.txt
rm -f /mnt/ifc/cfg/fast_link_failover_mode_latest.txt
rm -f $PREV_BOOT_IMAGE_SIGNATURE_FILE
rm -f /bootflash/high_power_optics_macsec.cfg
fi
touch /mnt/pss/.clean
sync
sleep 10
sync
date >> /bootflash/clean-config-log
if [ "$1" == "--keep-port-profile" -o "$1" == "-k" ]; then
if [ "$1" == "--keep-port-profile" ]; then
echo "setup-clean-config.sh --keep-port-profile is executed" >> /bootflash/clean-config-log
elif [ "$1" == "-k" ]; then
echo "setup-clean-config.sh -k is executed" >> /bootflash/clean-config-log
fi
else
echo "setup-clean-config.sh is executed" >> /bootflash/clean-config-log
fi
PARENT_COMMAND=$(ps -o args= $PPID)
echo "Caller process of setup-clean-config.sh: $PARENT_COMMAND" >> /bootflash/clean-config-log
echo >> /bootflash/clean-config-log
if [ -f /bootflash/clean-config-log ]; then
chmod 777 /bootflash/clean-config-log
fi
else
PARENT_COMMAND=$(ps -o args= $PPID)
bg_action /tmp/setup-clean-config $1
#date >> /bootflash/clean-config-log
#echo "Caller process of setup-clean-config.sh: $PARENT_COMMAND" >> /bootflash/clean-config-log
#echo >> /bootflash/clean-config-log
fi
/etc/isim_include¶
#! /bin/sh
####################################################################
#
# File: isim_include
#
# Copyright (c) 1985-2004, 2022-2023 by Cisco Systems, Inc.
# All rights reserved.
#
#####################################################################
. /etc/ins_card_index
ISIM_FILE=/bootflash/isim.conf
CARD_INDEX_TOR=$CARD_INDEX_NAGANO
SSD_PART1_ENFORCE_FILE="/bootflash/ssd_partition1"
TOR_CARD="TOR"
#fast_boot
PREV_BOOT_IMAGE_SIGNATURE_FILE="/mnt/pss/prev_boot_img_hdr"
PREV_SYSTEM_IMAGE_UNCOMPRESS_LOGFILE="/mnt/pss/prev_autos_uncompress.log"
FAST_BOOT_LOG_FILE="/tmp/fast_boot.log"
PREV_CORE_PLUGIN_EXTRACTION_LOG_FILE="/mnt/ifc/cfg/isan/plugin_extract_log/0"
PREV_ETH_PLUGIN_EXTRACTION_LOG_FILE="/mnt/ifc/cfg/isan/plugin_extract_log/1"
PREV_CORE_PLUGIN_SRG_FILE="/mnt/pss/.plugin_core_imgsrg.sro"
PREV_ETH_PLUGIN_SRG_FILE="/mnt/pss/.plugin_eth_imgsrg.sro"
PREV_UNKNOWN_PLUGIN_SRG_FILE="/mnt/pss/.plugin_unknown.sro"
SYSSRVC_CCTRL_RELOAD_MOD_STUB=0x59C
SYSSRV_CCTRL_GET_STATS_STUB=0x58F
SYSSRVC_CCTRL_SWITCH_RESET_STUB=0x58D
export ISANLOG_FILE=/var/log/isan.log
export log_it="/isanboot/bin/blogger -l$ISANLOG_FILE -- "
SYSMGR_LOG_FILE="/mnt/pss/bootlogs/current/sysmgr.log"
sysmgr_log() {
echo `date`: $1 >> $SYSMGR_LOG_FILE
}
bg_action() {
touch $1
echo ${@:2} > $1
while true
do
echo "In progress"
if [ -f $1 ]; then
sleep 5;
else
break
fi
done
echo "Done"
}
ins_clear_config() {
echo "Wipe out config as requested by earlier run"
/bin/rm -rf /mnt/ifc/cfg/db/*
/bin/rm -rf /logflash/log/*
# /bin/rm -rf /mnt/ifc/log/*
#do not delete last_run, lc_log dir created by S26check-flash-insime
#double checking for dir existance
if [ ! -d /mnt/ifc/log/last_run ]; then
mkdir -p /mnt/ifc/log/last_run
chmod 755 /mnt/ifc/log/last_run
echo "still missing last_run directory. created again..." >> /tmp/presysmgr.log
fi
for r in $(find /mnt/ifc/log -maxdepth 10 -type f);do rm -f $r;done
echo "Deleted all files in /mnt/ifc/log and sub-dir..." >> /tmp/presysmgr.log
used=`df -h /mnt/pss/logs | awk 'NR!=1 {print $5}' | cut -d'%' -f 1`
if [ $used -gt 70 ]; then
files=`ls -tr /mnt/pss/logs`
for file in $files;
do
/bin/rm -rf /mnt/pss/logs/$file
used=`df -h /mnt/pss/logs | awk 'NR!=1 {print $5}' | cut -d'%' -f 1`
if [ $used -lt 70 ]; then
break
fi
done
fi
/bin/rm -rf /mnt/ifc/cfg/avdb
if [ -f /mnt/pss/.debugMaintenanceMode ]; then
echo "Maintenance Mode - Debug - reload"
elif [ -f /mnt/pss/cleanup_flag ]; then
cp -pf /mnt/ifc/cfg/.apicConnectivity.xml /dev/shm/
/bin/rm -f /mnt/ifc/cfg/.apic*
cp -pf /dev/shm/.apicConnectivity.xml /mnt/ifc/cfg/
else
/bin/rm -f /mnt/ifc/cfg/.apic*
fi
# /bin/rm -f /mnt/ifc/cfg/fwd_scale_prof.txt
}
ins_clear_config_nxos_to_aci_conv() {
echo "NXOS to ACI conversion: deleting /mnt/ifc/cfg/db/*" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/rm -rf /mnt/ifc/cfg/db/*
echo "NXOS to ACI conversion: deleting /mnt/ifc/cfg/avdb/*" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/rm -rf /mnt/ifc/cfg/avdb/*
echo "NXOS to ACI conversion: deleting /mnt/ifc/log/*" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/rm -rf /mnt/ifc/log/*
echo "NXOS to ACI conversion: deleting /logflash/log/*" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/rm -rf /logflash/log/*
echo "NXOS to ACI conversion: deleting /logflash/core/*" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/rm -rf /logflash/core/*
echo "NXOS to ACI conversion: deleting /mnt/pss/*" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/mv /mnt/pss/nxos_to_aci_conv.log /tmp/nxos_to_aci_conv.log
/bin/rm -rf /mnt/pss/*
/bin/mv /tmp/nxos_to_aci_conv.log /mnt/pss/nxos_to_aci_conv.log
echo "NXOS to ACI conversion: deleting /bootflash/*.log *.LOG *.txt *.json *.gz" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/rm -rf /bootflash/*.log
/bin/rm -rf /bootflash/*.Log
/bin/rm -rf /bootflash/*.txt
/bin/rm -rf /bootflash/*.json
/bin/rm -rf /bootflash/*.gz
echo "NXOS to ACI conversion: purging NVRAM data" | tee -a /mnt/pss/nxos_to_aci_conv.log
/isanboot/bin/pfm_nvram_purge
echo "NXOS to ACI conversion: deleting /mnt/cfg/0/* files" | tee -a /mnt/pss/nxos_to_aci_conv.log
mv /mnt/cfg/0/boot/grub/menu.lst.local /tmp/menu.lst.local
/bin/rm -rf /mnt/cfg/0/*
mkdir -p /mnt/cfg/0/boot/grub
mv /tmp/menu.lst.local /mnt/cfg/0/boot/grub/menu.lst.local
echo "NXOS to ACI conversion: deleting /mnt/cfg/1/* files" | tee -a /mnt/pss/nxos_to_aci_conv.log
mv /mnt/cfg/1/boot/grub/menu.lst.local /tmp/menu.lst.local
/bin/rm -rf /mnt/cfg/1/*
mkdir -p /mnt/cfg/1/boot/grub
mv /tmp/menu.lst.local /mnt/cfg/1/boot/grub/menu.lst.local
}
get_sanos_debug_from_cmdline() {
sanos_debug=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q sanos_debug;
if [ $? == 0 ]; then
echo "Found $arg"
sanos_debug=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
}
get_kickstart_bash_from_cmdline() {
kickstart_bash=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q kickstart_bash;
if [ $? == 0 ]; then
echo "Found $arg"
kickstart_bash=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
}
get_server_ip_from_cmdline() {
my_card_index=$(cat /sys/kernel/cisco_board_info/card_index)
if [ $my_card_index -eq $CARD_INDEX_MOFF_GIDEON ]; then
ACTIVE_SUP_MOD_NUM=$(cat /sys/module/klm_cctrli/parameters/cctrl_cur_active_sup)
ACTIVE_SUP_MOD_NUM=$((ACTIVE_SUP_MOD_NUM+26))
server_ip="127.1.1.${ACTIVE_SUP_MOD_NUM}"
else
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q server_ip;
if [ $? == 0 ]; then
echo "Found $arg"
server_ip=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
fi
}
get_loader_ver_from_cmdline() {
loader_ver=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q loader_ver;
if [ $? == 0 ]; then
loader_ver=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
loader_ver=`echo $loader_ver | sed s/\"//g`
fi
done
}
isan_debug_isim() {
echo $1
if [ $sanos_debug -ge 2 ]; then
$log_it echo $1
fi
}
isan_error_isim() {
/isanboot/bin/blogger -V -l$ISANLOG_FILE -- echo $1
}
get_hw_changes_bits() {
HW_CHANGES_BITS=65535
if [[ -e /sys/kernel/cisco_board_info/hw_change_bits ]] ; then
HW_CHANGES_BITS=$(cat /sys/kernel/cisco_board_info/hw_change_bits)
fi
}
is_tor_ch() {
# check for valetine FPGA
pcino=$(/usr/bin/lspci -v | grep -i cisco | grep "177" | awk '{print $1}')
if [ ! -n "$pcino" ]; then
return 0
fi
addr=$(echo $pcino | xargs /usr/bin/lspci -v -s | grep "Memory at" | sed -n 2p | awk '{print $3}')
addr='0x'$addr
addr=`printf "0x%X\n" $((addr + 0x10bc))`
fpga_id1=`/usr/sbin/iorw r $addr w | awk '{print $2}'`
fpga_id1='0x'$fpga_id1
# check for churchill FPGA
pcino=$(/usr/bin/lspci -v | grep -i cisco | grep "17a" | awk '{print $1}')
if [ ! -n "$pcino" ]; then
return 0
fi
addr=$( echo $pcino | xargs /usr/bin/lspci -v -s | grep "Memory at" | awk '{print $3}')
addr='0x'$addr
addr=`printf "0x%X\n" $((addr + 0x10bc))`
fpga_id2=`/usr/sbin/iorw r $addr w | awk '{print $2}'`
fpga_id2='0x'$fpga_id2
if [[ $fpga_id1 == '0x10900177' ]] && [[ $fpga_id2 == '0x1070017a' ]]; then
return 1
fi
return 0
}
is_sup_the_child() {
# check for valetine FPGA
pcino=$(/usr/bin/lspci -v | grep -i cisco | grep "177" | awk '{print $1}')
if [ ! -n "$pcino" ]; then
return 0
fi
addr=$(echo $pcino | xargs /usr/bin/lspci -v -s | grep "Memory at" | sed -n 2p | awk '{print $3}')
addr='0x'$addr
addr=`printf "0x%X\n" $((addr + 0x10bc))`
fpga_id1=`/usr/sbin/iorw r $addr w | awk '{print $2}'`
fpga_id1='0x'$fpga_id1
# check for the_child FPGA
pcino=$(/usr/bin/lspci -v | grep -i cisco | grep "17e" | awk '{print $1}')
if [ ! -n "$pcino" ]; then
return 0
fi
addr=$( echo $pcino | xargs /usr/bin/lspci -v -s | grep "Memory at" | sed -n 1p | awk '{print $3}')
addr='0x'$addr
addr=`printf "0x%X\n" $((addr + 0x10bc))`
fpga_id2=`/usr/sbin/iorw r $addr w | awk '{print $2}'`
fpga_id2='0x'$fpga_id2
if [[ $fpga_id1 == '0x22000177' ]] && [[ $fpga_id2 == '0x2210017e' ]]; then
return 1
fi
return 0
}
get_card_index_from_cmdline() {
card_index=65535
is_tor_ch
ch_sts=$?
is_sup_the_child
child_sts=$?
if [[ -e /sys/kernel/cisco_board_info/card_index ]] ; then
card_index=$(cat /sys/kernel/cisco_board_info/card_index)
elif [ $ch_sts -eq 1 ]; then
card_index=$CARD_INDEX_CHURCHILL
echo "assigning card_index to $CARD_INDEX_CHURCHILL"
elif [ $child_sts -eq 1 ]; then
card_index=$CARD_INDEX_THE_CHILD_RP_1
echo "assigning card_index to $CARD_INDEX_THE_CHILD_RP_1"
else
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q card_index;
if [ $? == 0 ]; then
echo "Found $arg"
card_index=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
# this is a hack remove it
if [ $card_index -eq 21008 ]; then
card_index=$CARD_INDEX_CORTINA1
sed -i '/ISIM_CARD_INDEX/d' $ISIM_FILE
echo "ISIM_CARD_INDEX=21500" >> $ISIM_FILE
sync
fi
fi
done
fi
}
# For TORs that support dual-mode (can be either leaf or spine),
# the mode config file must exist; otherwise, defaulted to spine.
get_crdcfg_tor_card_mode()
{
local retval=0
# card_mode available only after FS mounted
if [[ ! -d "/mnt/ifc/cfg" ]]
then
echo " /mnt/ifc/cfg not exist " >> /tmp/presysmgr.log
retval=1
return $retval
fi
card_mode_file=/bootflash/crdcfg_card_mode.cfg
if [[ ! -f $card_mode_file ]]
then
echo -n "File $card_mode_file not found, " >> /tmp/presysmgr.log
echo "creating default mode for card_index $card_index" >> /tmp/presysmgr.log
if [ $card_index -eq $CARD_INDEX_SCULPIN ]; then
echo 0 > $card_mode_file
elif [ $card_index -eq $CARD_INDEX_MARIPOSA ]; then
echo 1 > $card_mode_file
elif [ $card_index -eq $CARD_INDEX_RED_HORSE ]; then
echo 1 > $card_mode_file
elif [ $card_index -eq $CARD_INDEX_DUVEL ]; then
echo 0 > $card_mode_file
elif [ $card_index -eq $CARD_INDEX_COASTAL_FOG ]; then
echo 1 > $card_mode_file
elif [ $card_index -eq $CARD_INDEX_PETRUS ]; then
echo 0 > $card_mode_file
elif [ $card_index -eq $CARD_INDEX_EDELWEISS ]; then
echo 0 > $card_mode_file
else
echo 1 > $card_mode_file
fi
fi
chattr -i $card_mode_file
current_card_mode=$(cat $card_mode_file)
if [[ "$current_card_mode" == "0" ]]; then
retval=0
elif [[ "$current_card_mode" == "1" ]]; then
retval=1
else
# Should not be here...something went wrong, the cfg file
# has invalid card mode value, recover it to spine mode
echo -n "Invalid card_mode $current_card_mode " >> /tmp/presysmgr.log
echo -n "found in file $card_mode_file, " >> /tmp/presysmgr.log
echo "default mode for card_index $card_index" >> /tmp/presysmgr.log
if [ $card_index -eq $CARD_INDEX_SCULPIN ]; then
echo 0 > $card_mode_file
retval=0
elif [ $card_index -eq $CARD_INDEX_MARIPOSA ]; then
echo 1 > $card_mode_file
retval=1
elif [ $card_index -eq $CARD_INDEX_RED_HORSE ]; then
echo 1 > $card_mode_file
retval=1
elif [ $card_index -eq $CARD_INDEX_DUVEL ]; then
echo 0 > $card_mode_file
retval=0
elif [ $card_index -eq $CARD_INDEX_COASTAL_FOG ]; then
echo 1 > $card_mode_file
retval=1
elif [ $card_index -eq $CARD_INDEX_PETRUS ]; then
echo 0 > $card_mode_file
retval=0
elif [ $card_index -eq $CARD_INDEX_EDELWEISS ]; then
echo 0 > $card_mode_file
retval=0
else
echo 1 > $card_mode_file
retval=1
fi
current_card_mode=$(cat $card_mode_file)
fi
chattr +i $card_mode_file
return $retval
}
COORS_FPGA_ID="0x1323826"
COORSPLUS_FPGA_ID="0x1497692"
MILLER_FPGA_ID="0x1263589"
get_mpa_id_from_cmdline() {
mpa_id=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q mpa_index;
if [ $? == 0 ]; then
echo "Found $arg"
mpa_id=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
if [ $card_index -ne $CARD_INDEX_OSLO -a $card_index -ne $CARD_INDEX_CALGARY -a $card_index -ne $CARD_INDEX_SAPPORO ]; then
if [ $mpa_id -eq 0 ]; then
# Try reading fpga_id to identify the MPA ID
don_addr=$(/usr/bin/lspci -v -d 1137:102 | grep "Memory"| awk '{print $3}')
don_addr_hex=0x$(echo | awk '{print substr("'"$don_addr"'",0,5)"004"}')
fpga_id=$(iorw r $don_addr_hex w | awk '{print $2}')
fpga_id="0x"$fpga_id
if [ "$fpga_id" == $COORS_FPGA_ID -o "$fpga_id" == $COORSPLUS_FPGA_ID ]; then
#COORS/COORS+
mpa_id=2
elif [ "$fpga_id" == $MILLER_FPGA_ID ]; then
#MILLER
mpa_id=1
fi
fi
fi
}
get_image_name_from_cmdline() {
image_name=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q ksimg;
if [ $? == 0 ]; then
echo "Found $arg"
image_name=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
}
get_is_recovery_img_from_cmdline() {
recovery_img=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q recovery;
if [ $? == 0 ]; then
echo "Found $arg"
recovery_img=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
}
get_first_setup_from_cmdline() {
first_setup=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q first_setup;
if [ $? == 0 ]; then
echo "Found $arg"
first_setup=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
}
get_sflc_debug_from_cmdline() {
sflc_debug=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q sflc_debug;
if [ $? == 0 ]; then
echo "Found $arg"
sflc_debug=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
}
get_hap_reset_from_cmdline() {
no_hap_reset_persist=0
no_hap_reset=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q no_hap_reset_persist;
if [ $? == 0 ]; then
echo "Found $arg"
no_hap_reset_persist=1
no_hap_reset=1
else
echo $arg | grep -q no_hap_reset;
if [ $? == 0 ]; then
echo "Found $arg"
no_hap_reset=1
fi
fi
done
}
mark_image_location() {
# Remove existing markings
rm -rf /mnt/cfg/0/recovery
rm -rf /mnt/cfg/1/recovery
rm -rf /mnt/cfg/0/main
rm -rf /mnt/cfg/1/main
# Mark it accordingly
get_is_recovery_img_from_cmdline
if [ $recovery_img -eq 1 ]; then
echo "Recovery image"
touch /mnt/cfg/0/recovery
touch /mnt/cfg/1/recovery
echo "Wipe out config"
rm -rf /mnt/ifc/cfg/db/*
else
echo "Main image"
touch /mnt/cfg/0/main
touch /mnt/cfg/1/main
fi
if [ -f /mnt/cfg/0/clean-config -o -f /mnt/cfg/1/clean-config ]; then
/bin/rm -rf /mnt/cfg/0/clean-config
/bin/rm -rf /mnt/cfg/1/clean-config
ins_clear_config
fi
if [ -f /mnt/pss/.clean ]; then
ins_clear_config
else
/bin/rm -f /mnt/pss/.debugMaintenanceMode
fi
}
create_conf_file() {
echo "Will generate isim.conf file for ToR simulation"
echo "ISIM_CHASSIS_MODEL=""TOR" > $ISIM_FILE
echo "ISIM_SLOT_ID=0" >> $ISIM_FILE
echo "ISIM_CARD_INDEX=$CARD_INDEX_TOR" >> $ISIM_FILE
echo "ISIM_CARD_TYPE=TOR" >> $ISIM_FILE
echo "ISIM_BASE_MAC=00:BA:5E:0D:00:00" >> $ISIM_FILE
}
get_chassis_model_from_conf_file() {
if [ -f $ISIM_FILE ]; then
chassis_model=`grep ISIM_CHASSIS_MODEL $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_nxos_pe_from_conf_file() {
if [ -f $ISIM_FILE ]; then
nxos_pe=`grep ISIM_INXOS_PE $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_slot_id_from_conf_file() {
if [ -f $ISIM_FILE ]; then
slot_id=`grep ISIM_SLOT_ID $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_card_index_from_conf_file() {
if [ -f $ISIM_FILE ]; then
card_index=`grep ISIM_CARD_INDEX $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
# this is a hack remove it
if [ $card_index -eq 21008 ]; then
card_index=$CARD_INDEX_CORTINA1
sed -i '/ISIM_CARD_INDEX/d' $ISIM_FILE
echo "ISIM_CARD_INDEX=21500" >> $ISIM_FILE
sync
fi
}
get_card_type_from_conf_file() {
if [ -f $ISIM_FILE ]; then
card_type=`grep ISIM_CARD_TYPE $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_base_mac_from_conf_file() {
if [ -f $ISIM_FILE ]; then
base_mac=`grep ISIM_BASE_MAC $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_mpa_id_from_conf_file() {
if [ -f $ISIM_FILE ]; then
mpa_id=`grep ISIM_MPA_ID $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_isim_ctrl_intf_from_conf_file() {
if [ -f $ISIM_FILE ]; then
isim_ctrl_intf=`grep ISIM_CTRL_INTERFACE $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_isim_infra_vlan_from_conf_file() {
if [ -f $ISIM_FILE ]; then
isim_infra_vlan=`grep ISIM_INFRA_VLAN $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_isim_global_accel_mode_from_conf_file() {
if [ -f $ISIM_FILE ]; then
isim_gl_accel_mode=`grep ISIM_ACCEL_MODE $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
publish_sim_pd_procfs() {
#Empty old content
echo -n "" > /proc/sim_pd
while read line
do
echo $line >> /proc/sim_pd
done </tmp/scale_phy_cfg_misc.out
}
get_env_platform() {
sim=0
IS_HW=1
#KIRKWOOD_SUP=0
TOR=0
TOR_LP=0
CORTINA1=0
CORTINA1_SDK=0
TOR_NG=0
TOR_OL=0
TOR_CY=0
TOR_SP=0
TOR_SQ=0
mpa_id=0
nxos_pe="na"
IS_TOR=0
IS_LEAF=0
SUPERVISOR=0
IS_SUP2=0
IS_ML=0
IS_LEM_CARD=0
TOR_GNBL=0
TOR_SLCITY=0
TOR_SEOUL=0
TOR_SEOUL2=0
TOR_TURIN=0
TOR_DEERVALLEY=0
IS_ATOM=0
IS_TACOMA=0
TOR_SUMPIN=0
TOR_DOPPLEBOCK=0
TOR_SHUGGA=0
TOR_FOSTERS=0
TOR_PIPEWORKS=0
TOR_PIPEDREAM=0
TOR_GRACELAND=0
SUP_ZION=0
TOR_SCRIMSHAW=0
TOR_SOUTHLAKE=0
TOR_MAIBOCK=0
TOR_KRIEK=0
TOR_TRUMER=0
TOR_ELYSIAN=0
TOR_TECATE=0
TOR_SCULPIN=0
TOR_SCULPIN_LEAF=0
TOR_MARIPOSA=0
TOR_MARIPOSA_SPINE=0
TOR_RED_HORSE=0
TOR_RED_HORSE_SPINE=0
TOR_ST_ARCHER=0
TOR_TUCHER=0
IS_FC_MT_BRAVE=0
IS_LC_BRASSWOOD=0
IS_FC_SHELDON=0
TOR_DUVEL=0
TOR_DUVEL_LEAF=0
TOR_COASTAL_FOG=0
TOR_COASTAL_FOG_SPINE=0
TOR_STELLER=0
TOR_PETRUS=0
TOR_PETRUS_LEAF=0
TOR_CHURCHILL=0
SUP_THE_CHILD=0
TOR_EDELWEISS=0
TOR_EDELWEISS_SPINE=0
IS_EDELWEISS=0
TOR_TRAPPIST=0
TOR_TRIPEL=0
IS_LC_BLACKBIRD=0
SR_CAPABLE=0
USE_PART_TYPE_V1=0
IS_SPINE=0
ENABLE_BIN_BASH=0
IS_LEM_CARD=0
IS_THE_CHILD_RP_1=0
IS_LC_MOFF_GIDEON=0
get_card_index_from_cmdline
if [ $card_index -eq 65535 ]; then
IS_HW=0
sim=1
get_card_index_from_conf_file
fi
# if cmdline is not set, look at isim.conf
if [ $nxos_pe == "na" ]; then
get_nxos_pe_from_conf_file
fi
if [ $nxos_pe == "MOCK" ]; then
INXOS_PE_MOCK=1
INXOS_PE_IFC=0
USE_PART_TYPE_V1=1
echo "*** Running INXOS PE MOCK image ***"
else
INXOS_PE_IFC=1
INXOS_PE_MOCK=0
nxos_pe="IFC"
fi
if [ -f /bootflash/platform.inf ]; then
if [ ! -z $(grep "ssd_partition=1" /bootflash/platform.inf 2>/dev/null) ]; then
USE_PART_TYPE_V1=1
fi
fi
if [ -f ${SSD_PART1_ENFORCE_FILE} ]; then
USE_PART_TYPE_V1=1
fi
if [ $card_index -eq $CARD_INDEX_KIRKWOOD ]; then
SUPERVISOR=1
usr_card_type=3
card_name="sup"
elif [ $card_index -eq $CARD_INDEX_KEYSTONE ]; then
SUPERVISOR=1
usr_card_type=3
card_name="sup2"
IS_SUP2=1
elif [ $card_index -eq $CARD_INDEX_ZION_A ]; then
SUPERVISOR=1
usr_card_type=3
card_name="sup2"
IS_SUP2=1
SUP_ZION=1
elif [ $card_index -eq $CARD_INDEX_ZION_B ]; then
SUPERVISOR=1
usr_card_type=3
card_name="sup2"
IS_SUP2=1
SUP_ZION=1
elif [ $card_index -eq $CARD_INDEX_SOCHI ]; then
TOR=1
usr_card_type=5
card_name="tor"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_PLACID ]; then
TOR_LP=1
usr_card_type=6
card_name="tor_lp"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_NAGANO ]; then
TOR_NG=1
usr_card_type=7
card_name="tor_ng"
NS_FPORT=97
elif [ $card_index -eq $CARD_INDEX_CORTINA1 ]; then
sim=0
IS_HW=1
CORTINA1=1
usr_card_type=9
card_name="c1"
elif [ $card_index -eq $CARD_INDEX_OSLO ]; then
TOR_OL=1
usr_card_type=10
card_name="tor_ol"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_CALGARY ]; then
TOR_CY=1
usr_card_type=11
card_name="tor_cy"
NS_FPORT=99
elif [ $card_index -eq $CARD_INDEX_SAPPORO ]; then
TOR_SP=1
usr_card_type=12
card_name="tor_sp"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_ML_BANFF ]; then
IS_ML=1
elif [ $card_index -eq $CARD_INDEX_GRENOBLE ]; then
TOR_GNBL=1
usr_card_type=13
card_name="tor_gnbl"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_SLCITY ]; then
TOR_SLCITY=1
usr_card_type=14
card_name="tor_slcity"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_SEOUL ]; then
TOR_SEOUL=1
usr_card_type=15
card_name="tor_seoul"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_SEOUL2 ]; then
TOR_SEOUL2=1
usr_card_type=25
card_name="tor_seoul2"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_TURIN ]; then
TOR_TURIN=1
usr_card_type=24
card_name="tor_turin"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_SQUAWVALLEY ]; then
TOR_SQ=1
usr_card_type=16
card_name="tor_sq"
NS_FPORT=97
elif [ $card_index -eq $CARD_INDEX_CANYON ]; then
IS_ATOM=1
usr_card_type=17
elif [ $card_index -eq $CARD_INDEX_MT_KATO ]; then
IS_ATOM=1
usr_card_type=18
elif [ $card_index -eq $CARD_INDEX_COPPER_MTN ]; then
IS_ATOM=1
usr_card_type=19
elif [ $card_index -eq $CARD_INDEX_SHAWNEE ]; then
IS_ATOM=1
usr_card_type=20
elif [ $card_index -eq $CARD_INDEX_CASCADES ]; then
IS_ATOM=1
usr_card_type=21
elif [ $card_index -eq $CARD_INDEX_TACOMA ]; then
IS_ATOM=1
IS_TACOMA=1
usr_card_type=23
elif [ $card_index -eq $CARD_INDEX_DEERVALLEY ]; then
TOR_DEERVALLEY=1
usr_card_type=22
card_name="tor_deervalley"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_SUMPIN ]; then
TOR_SUMPIN=1
usr_card_type=26
card_name="tor_sumpin"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_SHUGGA ]; then
TOR_SHUGGA=1
usr_card_type=27
card_name="tor_shugga"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_FOSTERS ]; then
TOR_FOSTERS=1
usr_card_type=28
card_name="tor_fosters"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_BLUEWOOD ]; then
IS_ATOM=1
usr_card_type=30
elif [ $card_index -eq $CARD_INDEX_DOPPLEBOCK ]; then
TOR_DOPPLEBOCK=1
usr_card_type=29
card_name="tor_dopplebock"
CORTINA1_SDK=1
NS_FPORT=66
elif [ $card_index -eq $CARD_INDEX_MT_BAKER ]; then
IS_ATOM=1
usr_card_type=31
elif [ $card_index -eq $CARD_INDEX_PIPEWORKS ]; then
TOR_PIPEWORKS=1
usr_card_type=32
card_name="tor_pipeworks"
NS_FPORT=54
elif [ $card_index -eq $CARD_INDEX_PIPEDREAM ]; then
TOR_PIPEDREAM=1
usr_card_type=33
card_name="tor_pipedream"
NS_FPORT=54
elif [ $card_index -eq $CARD_INDEX_GRACELAND ]; then
TOR_GRACELAND=1
usr_card_type=45
card_name="tor_graceland"
NS_FPORT=10
elif [ $card_index -eq $CARD_INDEX_MT_EVEREST ]; then
IS_ATOM=1
usr_card_type=34
elif [ $card_index -eq $CARD_INDEX_SCRIMSHAW ]; then
TOR_SCRIMSHAW=1
usr_card_type=35
card_name="tor_scrimshaw"
NS_FPORT=36
elif [ $card_index -eq $CARD_INDEX_KRIEK ]; then
TOR_KRIEK=1
usr_card_type=38
card_name="tor_kriek"
NS_FPORT=108
elif [ $card_index -eq $CARD_INDEX_TRUMER ]; then
TOR_TRUMER=1
usr_card_type=39
card_name="tor_trumer"
NS_FPORT=108
elif [ $card_index -eq $CARD_INDEX_SOUTHLAKE ]; then
TOR_SOUTHLAKE=1
usr_card_type=36
card_name="tor_southlake"
NS_FPORT=66
elif [ $card_index -eq $CARD_INDEX_MAIBOCK ]; then
TOR_MAIBOCK=1
usr_card_type=37
card_name="tor_maibock"
CORTINA1_SDK=1
NS_FPORT=34
elif [ $card_index -eq $CARD_INDEX_ELYSIAN ]; then
TOR_ELYSIAN=1
usr_card_type=40
card_name="tor_elysian"
NS_FPORT=54
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_TECATE ]; then
TOR_TECATE=1
usr_card_type=41
card_name="tor_tecate"
NS_FPORT=54
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_SCULPIN ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_SCULPIN=1
CORTINA1_SDK=1
else
TOR_SCULPIN_LEAF=1
fi
usr_card_type=42
card_name="tor_sculpin"
NS_FPORT=16
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_MARIPOSA ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_MARIPOSA_SPINE=1
CORTINA1_SDK=1
else
TOR_MARIPOSA=1
fi
usr_card_type=43
card_name="tor_mariposa"
NS_FPORT=36
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_ST_ARCHER ]; then
TOR_ST_ARCHER=1
usr_card_type=46
card_name="tor_st_archer"
NS_FPORT=108
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_TUCHER ]; then
TOR_TUCHER=1
usr_card_type=47
card_name="tor_tucher"
NS_FPORT=108
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_MT_BRAVE ]; then
IS_ATOM=1
IS_FC_MT_BRAVE=1
usr_card_type=48
elif [ $card_index -eq $CARD_INDEX_BRASSWOOD ]; then
IS_ATOM=1
IS_LC_BRASSWOOD=1
usr_card_type=49
elif [ $card_index -eq $CARD_INDEX_SHELDON ]; then
IS_ATOM=1
IS_FC_SHELDON=1
usr_card_type=50
elif [ $card_index -eq $CARD_INDEX_RED_HORSE ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_RED_HORSE_SPINE=1
CORTINA1_SDK=1
else
TOR_RED_HORSE=1
fi
usr_card_type=44
card_name="tor_red_horse"
NS_FPORT=64
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_DUVEL ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_DUVEL=1
CORTINA1_SDK=1
else
TOR_DUVEL_LEAF=1
fi
usr_card_type=51
card_name="tor_duvel"
NS_FPORT=66
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_COASTAL_FOG ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_COASTAL_FOG_SPINE=1
CORTINA1_SDK=1
else
TOR_COASTAL_FOG=1
fi
usr_card_type=52
card_name="tor_coastal_fog"
NS_FPORT=34
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_STELLER ]; then
TOR_STELLER=1
usr_card_type=53
card_name="tor_steller"
NS_FPORT=36
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_PETRUS ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_PETRUS=1
CORTINA1_SDK=1
else
TOR_PETRUS_LEAF=1
fi
usr_card_type=54
card_name="tor_petrus"
NS_FPORT=48
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_CHURCHILL ]; then
TOR_CHURCHILL=1
usr_card_type=55
card_name="tor_churchill"
CORTINA1_SDK=1 # Radha TODO
NS_FPORT=32 # Radha TODO
elif [ $card_index -eq $CARD_INDEX_THE_CHILD_RP_1 ]; then
SUPERVISOR=1
usr_card_type=56
card_name="mando_the_child"
IS_SUP2=1
SUP_THE_CHILD=1
IS_LEM_CARD=1
IS_THE_CHILD_RP_1=1
elif [ $card_index -eq $CARD_INDEX_MOFF_GIDEON ]; then
# IS_ATOM=1
IS_LC_MOFF_GIDEON=1
usr_card_type=58
elif [ $card_index -eq $CARD_INDEX_EDELWEISS ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_EDELWEISS_SPINE=1
CORTINA1_SDK=1
else
TOR_EDELWEISS=1
fi
IS_LEM_CARD=1
IS_EDELWEISS=1
usr_card_type=57
card_name="tor_edelweiss"
NS_FPORT=8
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_TRAPPIST ]; then
TOR_TRAPPIST=1
usr_card_type=60
card_name="tor_trappist"
NS_FPORT=54
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_TRIPEL ]; then
TOR_TRIPEL=1
usr_card_type=61
card_name="tor_tripel"
NS_FPORT=54
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_BLACKBIRD ]; then
IS_ATOM=1
IS_LC_BLACKBIRD=1
usr_card_type=62
fi
if [ $card_index -eq $CARD_INDEX_NAGANO -o $card_index -eq $CARD_INDEX_SOCHI -o $card_index -eq $CARD_INDEX_PLACID -o \
$card_index -eq $CARD_INDEX_OSLO -o $card_index -eq $CARD_INDEX_CALGARY -o $card_index -eq $CARD_INDEX_SAPPORO -o \
$card_index -eq $CARD_INDEX_GRENOBLE -o $card_index -eq $CARD_INDEX_SLCITY -o $card_index -eq $CARD_INDEX_SQUAWVALLEY -o \
$card_index -eq $CARD_INDEX_SUMPIN -o $card_index -eq $CARD_INDEX_SHUGGA -o $card_index -eq $CARD_INDEX_FOSTERS -o \
$card_index -eq $CARD_INDEX_SEOUL -o $card_index -eq $CARD_INDEX_DEERVALLEY -o $card_index -eq $CARD_INDEX_TURIN -o \
$card_index -eq $CARD_INDEX_SEOUL2 -o $card_index -eq $CARD_INDEX_DOPPLEBOCK -o $card_index -eq $CARD_INDEX_PIPEWORKS -o \
$card_index -eq $CARD_INDEX_SCRIMSHAW -o $card_index -eq $CARD_INDEX_PIPEDREAM -o $card_index -eq $CARD_INDEX_SOUTHLAKE -o \
$card_index -eq $CARD_INDEX_GRACELAND -o $card_index -eq $CARD_INDEX_MARIPOSA -o \
$card_index -eq $CARD_INDEX_KRIEK -o $card_index -eq $CARD_INDEX_TRUMER -o $card_index -eq $CARD_INDEX_ELYSIAN -o \
$card_index -eq $CARD_INDEX_TECATE -o $card_index -eq $CARD_INDEX_MAIBOCK -o $card_index -eq $CARD_INDEX_SCULPIN -o \
$card_index -eq $CARD_INDEX_ST_ARCHER -o $card_index -eq $CARD_INDEX_TUCHER -o $card_index -eq $CARD_INDEX_RED_HORSE -o \
$card_index -eq $CARD_INDEX_DUVEL -o $card_index -eq $CARD_INDEX_COASTAL_FOG -o $card_index -eq $CARD_INDEX_STELLER -o \
$card_index -eq $CARD_INDEX_PETRUS -o $card_index -eq $CARD_INDEX_EDELWEISS -o $card_index -eq $CARD_INDEX_TRAPPIST -o \
$card_index -eq $CARD_INDEX_CHURCHILL -o $card_index -eq $CARD_INDEX_TRIPEL ]; then
IS_TOR=1
fi
if [ $IS_TOR -eq 1 -a $card_index -ne $CARD_INDEX_DOPPLEBOCK -a $card_index -ne $CARD_INDEX_MAIBOCK -a \
$card_index -ne $CARD_INDEX_SCULPIN -a $card_index -ne $CARD_INDEX_DUVEL -a \
$card_index -ne $CARD_INDEX_PETRUS -a $card_index -ne $CARD_INDEX_CHURCHILL ]; then
IS_LEAF=1
fi
if [ $card_index -eq $CARD_INDEX_ML_BANFF ]; then
TOR=1
IS_TOR=1
usr_card_type=5
card_name="tor"
INXOS_PE_MOCK=1
INXOS_PE_IFC=0
nxos_pe="MOCK"
NS_FPORT=33
fi
if [ $IS_TOR -eq 1 ]; then
if [ $card_index -eq $CARD_INDEX_DOPPLEBOCK ] || \
[ $card_index -eq $CARD_INDEX_CHURCHILL ] || \
[ $card_index -eq $CARD_INDEX_MAIBOCK ] || \
[ $TOR_DUVEL -eq 1 ] || \
[ $TOR_COASTAL_FOG_SPINE -eq 1 ] || \
[ $TOR_SCULPIN -eq 1 ] || \
[ $TOR_MARIPOSA_SPINE -eq 1 ] || \
[ $TOR_EDELWEISS_SPINE -eq 1 ] || \
[ $TOR_RED_HORSE_SPINE -eq 1 ] || \
[ $TOR_PETRUS -eq 1 ] || \
[ $card_index -eq $CARD_INDEX_CORTINA1 ]; then
IS_SPINE=1
fi
else
IS_SPINE=1
fi
minicore=false
for arg in `cat /proc/cmdline`
do
case "${arg}" in
minicore)
minicore=true;
esac
done
if [ -f /bootflash/platform.inf ]; then
if [ ! -z $(grep "enable_bin_bash=1" /bootflash/platform.inf) ]; then
ENABLE_BIN_BASH=1
fi
fi
if [ -f /bootflash/enable_bin_bash ] && [ "`/isanboot/bin/bldreport type`" = "gdb" ]; then
ENABLE_BIN_BASH=1
fi
}
get_hw_sup_slots()
{
my_card_index=$(cat /sys/kernel/cisco_board_info/card_index)
if [ $my_card_index -eq $CARD_INDEX_THE_CHILD_RP_1 ]; then
# slot_id=$(cat /sys/kernel/cisco_board_info/slot_index)
slot_id_data=`/usr/sbin/iorw r 0xb1031080 w`
slot_id=`echo $slot_id_data | awk '{print substr($0, 7, 2)}'`
slot_id_hex=$((slot_id + 27))
else
slot_id_data=`/usr/sbin/iorw r 0xe800000c b`
slot_id=`echo $slot_id_data | awk '{print substr($0, 7, 2)}'`
slot_id_hex='0x'$slot_id
# Make sure to take only the 5 least significant bits.
slot_id_hex=$((slot_id_hex&0x1f))
fi
sup_slot_id=$slot_id_hex
if [ $sup_slot_id -eq 27 ]; then
other_sup_slot_id=28
else
other_sup_slot_id=27
fi
}
setup_diag_bootup_level_file()
{
if [ -f /mnt/bootflash/diag_bootup ]; then
cp /mnt/bootflash/diag_bootup /tmp/diag_bootup
rm -rf /mnt/bootflash/diag_bootup
fi
}
# cleanup all files not needed by tahoe platforms on line cards
ins_clean_non_tahoe_files() {
echo "Cleaning up non tahoe specific files" >> /tmp/presysmgr.log
rm -rf /lc/isan/bin/ishell*
rm -rf /lc/isan/bin/nsausd
rm -rf /lc/isan/bin/t2usd
rm -rf /lc/isan/bin/inssim.exe
rm -rf /lc/isan/bin/lcm_itest
rm -rf /lc/isan/sdkbin.tar.gz
rm -rf /lc/isan/sdktools.tar.gz
rm -rf /lc/isan/sdklib.tar.gz
rm -rf /lc/isan/sdkconf.tar.gz
rm -rf /lc/isan/lib/libbcm*
rm -rf /usr/lib/perl
rm -rf /lc/isan/lib/libtahoe_dummy.so
}
# Not all sim setups support 9 partitions
# On the ones there is support map paritions like in hw so that
# ifc mode works seamlessly.
ins_sim_supports_sda9() {
sda9_present=0
if [ -e /dev/sda9 ]; then
sda9_present=1
fi
echo "Checking for /dev/sda9 for sim : $sda9_present"
}
collect_stby_logs() {
echo "Collecting logs on stby"
if [[ -e /tmp/stby_logs ]] ; then
echo "stby logs are already collected"
return
fi
touch /tmp/stby_logs
rm -rf /bootflash/tmp
mkdir /bootflash/tmp
cd /bootflash/tmp
dmesg > dmesg
tar czf mnt_pss.tar.gz /mnt/pss
tar czf mnt_pstore.tar.gz /mnt/pstore
tar czf mnt_ifc_log.tar.gz /mnt/ifc/log/last_run
rm /bootflash-remote/stby_tech_*
tar czf stby_tech_$(date +%Y%m%d-%H%M%S).tar.gz .
#copy the file if more than 20% available on remote bootflash after copy
remote_size=$(df -B 1024 /bootflash-remote | grep bootflash | awk '{print $2}')
remote_available_size=$(df -B 1024 /bootflash-remote | grep bootflash | awk '{print $4}')
tar_file_size=$(du -s -B 1024 stby_tech* | awk '{print $1}')
if [[ ( $tar_file_size -lt $remote_available_size ) &&
( $(( (remote_available_size - tar_file_size) * 100 / remote_size )) -gt 20 )]] ; then
cp stby_tech* /bootflash-remote
else
echo "not enough memory to copy stby logs"
fi
cd ..
rm -rf /bootflash/tmp
}
clear_n9k_cpa_files() {
# clear n9k_cpa files
#[ ! -d /isan/lib/n9k_cpa ] || rm -rf /isan/lib/n9k_cpa
#[ ! -d /isan/bin/n9k_cpa ] || rm -rf /isan/bin/n9k_cpa
[ ! -d /usr/lib64/n9k_cpa ] || rm -rf /usr/lib64/n9k_cpa
[ ! -d /usr/bin/n9k_cpa ] || rm -rf /usr/bin/n9k_cpa
[ ! -d /usr/local/etc/n9k-cpa-data ] || rm -rf /usr/local/etc/n9k-cpa-data
[ ! -d /lc/isan/lib/n9k_cpa ] || rm -rf /lc/isan/lib/n9k_cpa
[ ! -d /lc/isan/bin/n9k_cpa ] || rm -rf /lc/isan/bin/n9k_cpa
}
setup_xrcpa_sb_lib_files() {
lib_path=$1
sb_lib=$2
sb_sprom_lib=$3
# setup xr_cpa file
if [ -f $lib_path/xr_cpa/$sb_lib ] ; then
rm -rf $lib_path/xr_cpa/libcpa_sb.so*
rm -rf $lib_path/xr_cpa/libplatform-cpa-sb-sprom.so*
ln -s $lib_path/xr_cpa/$sb_lib $lib_path/xr_cpa/libcpa_sb.so.0.0.0
ln -s $lib_path/xr_cpa/$sb_lib $lib_path/xr_cpa/libcpa_sb.so.0
ln -s $lib_path/xr_cpa/$sb_lib $lib_path/xr_cpa/libcpa_sb.so
ln -s $lib_path/xr_cpa/$sb_sprom_lib $lib_path/xr_cpa/libplatform-cpa-sb-sprom.so.0.0.0
ln -s $lib_path/xr_cpa/$sb_sprom_lib $lib_path/xr_cpa/libplatform-cpa-sb-sprom.so
ln -s $lib_path/xr_cpa/$sb_sprom_lib $lib_path/xr_cpa/libplatform-cpa-sb-sprom.so.0
#boot_debug "Linked $lib_path/xr_cpa/$sb_lib"
else
echo "Error: CPA SB lib not found"
fi
}
setup_xrcpa_lib_symlinks() {
target_path=$1
typ=$2
link_path=$3
# setup xr_cpa file
for f in $target_path/$typ/xr_cpa/*
do
# TO DO MANDO/XR: Checking if file exists should not be needed
# Check why there are multiple libraries.
[ -e $link_path/${f##*/} ] || ln -s $f $link_path/${f##*/}
# TO DO MANDO/XR: some libraries are dlopened as so.1 change to .so if possible
if [ "$typ" = "lib" ] || [ "$typ" = "lib64" ]; then
[ -e $link_path/${f##*/}.1 ] || ln -s $f $link_path/${f##*/}.1
fi
done
}
xr_iofpga_wr()
{
base_addr=$1
offset=$2
val=$3
echo "CHASSIS SYNC: writing $val to $offset" >> /tmp/chassis_sync.log 2>&1
/lc/isan/bin/iorw w $(printf "0x%x" $(($base_addr + $offset))) $val w >> /tmp/chassis_sync.log 2>&1
}
xr_chassis_sync()
{
io_base_addr=$((0x$(cat /proc/bus/pci/devices | grep 1137017a | cut -f4 | tr -d ' ') & 0xfffffff0))
xr_iofpga_wr $io_base_addr 0x1108 0xa0602
xr_iofpga_wr $io_base_addr 0x110c 0x10000
xr_iofpga_wr $io_base_addr 0x1110 0x38303838
xr_iofpga_wr $io_base_addr 0x1114 0x0
xr_iofpga_wr $io_base_addr 0x1118 0x0
xr_iofpga_wr $io_base_addr 0x111c 0x0
xr_iofpga_wr $io_base_addr 0x1120 0x0
xr_iofpga_wr $io_base_addr 0x1124 0x32584f46
xr_iofpga_wr $io_base_addr 0x1128 0x50323135
xr_iofpga_wr $io_base_addr 0x112c 0x4d5830
xr_iofpga_wr $io_base_addr 0x1104 0x01000001
# Reset/Restore correct block offsets for kirkwall
xr_iofpga_wr $io_base_addr 0x44 0x00100010
xr_iofpga_wr $io_base_addr 0x48 0x001000d0
xr_iofpga_wr $io_base_addr 0x4c 0x00100010
xr_iofpga_wr $io_base_addr 0x50 0x00100010
xr_iofpga_wr $io_base_addr 0x54 0x00100010
xr_iofpga_wr $io_base_addr 0x58 0x00100010
xr_iofpga_wr $io_base_addr 0x5c 0x00100020
xr_iofpga_wr $io_base_addr 0x60 0x00100010
xr_iofpga_wr $io_base_addr 0x64 0x00100010
xr_iofpga_wr $io_base_addr 0x68 0x00100010
xr_iofpga_wr $io_base_addr 0x6c 0x00200010
xr_iofpga_wr $io_base_addr 0x70 0x00800010
xr_iofpga_wr $io_base_addr 0x74 0x00300010
xr_iofpga_wr $io_base_addr 0x78 0x00200030
xr_iofpga_wr $io_base_addr 0x7c 0x00800080
xr_iofpga_wr $io_base_addr 0x80 0x00100080
xr_iofpga_wr $io_base_addr 0x84 0x00200010
xr_iofpga_wr $io_base_addr 0x88 0x00200020
xr_iofpga_wr $io_base_addr 0x8c 0x00200020
xr_iofpga_wr $io_base_addr 0x90 0x00200020
xr_iofpga_wr $io_base_addr 0x94 0x00200020
xr_iofpga_wr $io_base_addr 0x98 0x00200020
xr_iofpga_wr $io_base_addr 0x9c 0x00200020
xr_iofpga_wr $io_base_addr 0xa0 0x00200020
xr_iofpga_wr $io_base_addr 0xa4 0x00200020
xr_iofpga_wr $io_base_addr 0xa8 0x001000c0
xr_iofpga_wr $io_base_addr 0xac 0x01800010
xr_iofpga_wr $io_base_addr 0xb0 0x01800180
xr_iofpga_wr $io_base_addr 0xb4 0x01800180
xr_iofpga_wr $io_base_addr 0xb8 0x00100010
xr_iofpga_wr $io_base_addr 0xbc 0x00100010
xr_iofpga_wr $io_base_addr 0xc0 0x00000030
xr_iofpga_wr $io_base_addr 0xc4 0x00000000
xr_iofpga_wr $io_base_addr 0xc8 0x00000000
xr_iofpga_wr $io_base_addr 0xcc 0x00000000
xr_iofpga_wr $io_base_addr 0xd0 0x00000000
xr_iofpga_wr $io_base_addr 0xd4 0x00000000
xr_iofpga_wr $io_base_addr 0xd8 0x00000000
xr_iofpga_wr $io_base_addr 0xdc 0x00000000
xr_iofpga_wr $io_base_addr 0xe0 0x00000000
xr_iofpga_wr $io_base_addr 0xe4 0x00000000
xr_iofpga_wr $io_base_addr 0xe8 0x00000000
xr_iofpga_wr $io_base_addr 0xec 0x00000000
xr_iofpga_wr $io_base_addr 0xf0 0x00000000
xr_iofpga_wr $io_base_addr 0xf4 0x00000000
xr_iofpga_wr $io_base_addr 0xf8 0x00000000
}
setup_xr_cpa() {
local card_index=$1
platform="XR platform"
clear_n9k_cpa_files
ln -s /usr/local/etc/xr-cpa-data/fru-db.json /usr/local/etc/fru-db.json
ln -s /usr/local/etc/xr-cpa-data/cpa-yaml /usr/local/etc/cpa-yaml
xrcpa_dest_libpath=/usr/lib64
xrcpa_dest_binpath=/usr/bin
echo "setup_xr_cpa:1300" >> /tmp/presysmgr.log
if [ $card_index -eq $CARD_INDEX_THE_CHILD_RP_1 ]; then
echo "setup_xr_cpa:1310" >> /tmp/presysmgr.log
setup_xrcpa_sb_lib_files $xrcpa_dest_libpath libcpa_sb_8800_rp_1_0_x86_api.so.0.0.0 libidprom-platform-8800-rp.so.0.0.0
#setup_xrcpa_lib_symlinks /isan lib /isan/lib
#setup_xrcpa_lib_symlinks /isan lib /usr/lib64/
#setup_xrcpa_lib_symlinks /isan bin /isan/bin
##setup_xrcpa_lib_symlinks /isan bin /usr/lib64/
setup_xrcpa_lib_symlinks /usr lib64 /usr/lib64/
setup_xrcpa_lib_symlinks /usr bin /usr/bin/
$xrcpa_dest_binpath/spitfire_bootstrap > /tmp/bootstrap.log 2>&1
platform="MANDO RP"
elif [ $card_index -eq $CARD_INDEX_MOFF_GIDEON ]; then
setup_xrcpa_sb_lib_files /lc/isan/lib libcpa_sb_vanguard_1_0_x86_api.so.0.0.0 libidprom-platform-8800-lc-36fh-m.so.0.0.0
setup_xrcpa_lib_symlinks /lc/isan lib /lc/isan/lib
setup_xrcpa_lib_symlinks /lc/isan lib /usr/lib64/
setup_xrcpa_lib_symlinks /lc/isan bin /lc/isan/bin
# MANDO TO DO: temporary chassis_sync change
xr_chassis_sync
/lc/isan/bin/spitfire_bootstrap > /tmp/bootstrap.log 2>&1
platform="MANDO LC VG"
elif [ $card_index -eq $CARD_INDEX_AXE_WOVES ]; then
setup_xrcpa_sb_lib_files /lc/isan/lib libcpa_sb_lancer_1_0_x86_api.so.0.0.0 libidprom-platform-8800-lc-36fh-m.so.0.0.0
setup_xrcpa_lib_symlinks /lc/isan lib /lc/isan/lib
setup_xrcpa_lib_symlinks /lc/isan lib /usr/lib64/
setup_xrcpa_lib_symlinks /lc/isan bin /lc/isan/bin
# MANDO TO DO: temporary chassis_sync change
xr_chassis_sync
/lc/isan/bin/spitfire_bootstrap > /tmp/bootstrap.log 2>&1
platform="MANDO LC LN"
else
#Assume TORs (sup only)
if [ $card_index -eq $CARD_INDEX_CHURCHILL ]; then
# sup
setup_xrcpa_sb_lib_files $xrcpa_dest_libpath libcpa_sb_8201_32fh_1_0_x86_api.so.0.0.0 libidprom-platform-8201-32fh.so.0.0.0
platform="Churchill"
fi
# TO DO: Review if seperate lc/sup is necessary for TORs
#setup_xrcpa_lib_symlinks /isan lib /isan/lib
#setup_xrcpa_lib_symlinks /isan lib /usr/lib64/
#setup_xrcpa_lib_symlinks /isan bin /isan/bin
setup_xrcpa_lib_symlinks /usr lib64 /usr/lib64/
setup_xrcpa_lib_symlinks /usr bin /usr/bin
#/isanboot/bin/spitfire_bootstrap > /tmp/bootstrap.log 2>&1
fi
echo "$platform CPA setup done"
}
setup_xr_cpa_tor_lc() {
local card_index=$1
platform="XR platform"
clear_n9k_cpa_files
if [ $card_index -eq $CARD_INDEX_CHURCHILL ]; then
# lc
setup_xrcpa_sb_lib_files /lc/isan/lib libcpa_sb_8201_32fh_1_0_x86_api.so.0.0.0 libidprom-platform-8201-32fh.so.0.0.0
platform="Churchill LC"
fi
# TO DO: Review if seperate lc/sup is necessary for TORs
setup_xrcpa_lib_symlinks /lc/isan lib /lc/isan/lib
setup_xrcpa_lib_symlinks /lc/isan bin /lc/isan/bin
echo "$platform CPA setup done"
}
clear_xr_cpa() {
# clear xr_cpa files
#[ ! -d /isan/lib/xr_cpa ] || rm -rf /isan/lib/xr_cpa
#[ ! -d /isan/bin/xr_cpa ] || rm -rf /isan/bin/xr_cpa
[ ! -d /usr/lib64/xr_cpa ] || rm -rf /usr/lib64/xr_cpa
[ ! -d /usr/bin/xr_cpa ] || rm -rf /usr/bin/xr_cpa
[ ! -d /usr/local/etc/xr-cpa-data ] || rm -rf /usr/local/etc/xr-cpa-data
[ ! -d /lc/isan/lib/xr_cpa ] || rm -rf /lc/isan/lib/xr_cpa
[ ! -d /lc/isan/bin/xr_cpa ] || rm -rf /lc/isan/bin/xr_cpa
}
setup_n9k_cpa() {
local card_index=$1
# clear xr_cpa files
clear_xr_cpa
# setup n9k_cpa files (Default behavior)
#[ ! -d /isan/lib/n9k_cpa ] || mv /isan/lib/n9k_cpa/* /isan/lib/
#[ ! -d /isan/bin/n9k_cpa ] || mv /isan/bin/n9k_cpa/* /isan/bin/
[ ! -d /usr/lib64/n9k_cpa ] || mv /usr/lib64/n9k_cpa/* /isan/lib/
[ ! -d /usr/bin/n9k_cpa ] || mv /usr/bin/n9k_cpa/* /isan/bin/
[ ! -d /usr/local/etc/n9k-cpa-data ] || mv /usr/local/etc/n9k-cpa-data/* /usr/local/etc/
#[ ! -d /lc/isan/lib/n9k_cpa ] || mv /lc/isan/lib/n9k_cpa/* /lc/isan/lib/
#[ ! -d /lc/isan/bin/n9k_cpa ] || mv /lc/isan/bin/n9k_cpa/* /lc/isan/bin/
if [ $card_index == 21223 ]; then
cp /isan/lib/libcpa_sb_nxos_exa.so /isan/lib/libcpa_sb_nxos.so
#cp /usr/lib64/libcpa_sb_nxos_exa.so /usr/lib64/libcpa_sb_nxos.so
#cp /lc/isan/lib/libcpa_sb_nxos_exa.so /lc/isan/lib/libcpa_sb_nxos.so
fi
if [ -f "/isan/lib/libcpa_sb_nxos.so.0.0.0" ]; then
rm /isan/lib/libcpa_sb.so.0.0.0
ln -s /isan/lib/libcpa_sb_nxos.so.0.0.0 /isan/lib/libcpa_sb.so.0.0.0
#rm /usr/lib64/libcpa_sb.so
#ln -s /usr/lib64/libcpa_sb_nxos.so /usr/lib64/libcpa_sb.so
#boot_debug "Linked /isan/lib/libcpa_sb_nxos.so"
fi
echo "N9K CPA setup done"
}
setup_n9k_cpa_tor_lc() {
local card_index=$1
# clear xr_cpa files
clear_xr_cpa
# setup n9k_cpa files
#[ ! -d /isan/lib/n9k_cpa ] || mv /isan/lib/n9k_cpa/* /isan/lib/
#[ ! -d /isan/bin/n9k_cpa ] || mv /isan/bin/n9k_cpa/* /isan/bin/
#[ ! -d /usr/local/etc/n9k-cpa-data ] || mv /usr/local/etc/n9k-cpa-data/* /usr/local/etc/
[ ! -d /lc/isan/lib/n9k_cpa ] || mv /lc/isan/lib/n9k_cpa/* /lc/isan/lib/
[ ! -d /lc/isan/bin/n9k_cpa ] || mv /lc/isan/bin/n9k_cpa/* /lc/isan/bin/
[ ! -d /usr/local/etc/n9k-cpa-data/cpa-yaml ] || mv /usr/local/etc/n9k-cpa-data/cpa-yaml /usr/local/etc/
[ ! -f /usr/local/etc/n9k-cpa-data/fru-db.json ] || mv /usr/local/etc/n9k-cpa-data/fru-db.json /usr/local/etc/
if [ $card_index == 21223 ]; then
#cp /isan/lib/libcpa_sb_nxos_exa.so /isan/lib/libcpa_sb_nxos.so
cp /lc/isan/lib/libcpa_sb_nxos_exa.so /lc/isan/lib/libcpa_sb_nxos.so
fi
if [ -f "/lc/isan/lib/libcpa_sb_nxos.so.0.0.0" ]; then
rm /lc/isan/lib/libcpa_sb.so.0.0.0
ln -s /lc/isan/lib/libcpa_sb_nxos.so.0.0.0 /lc/isan/lib/libcpa_sb.so.0.0.0
#boot_debug "Linked /lc/isan/lib/libcpa_sb_nxos.so"
fi
echo "N9K TOR LC CPA setup done"
}
setup_cpa_sup_boot() {
local card_index=$1
case $card_index in
$CARD_INDEX_THE_CHILD_RP_1 | $CARD_INDEX_CHURCHILL )
setup_xr_cpa $card_index
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isanboot/lib/libpal_cpa.so.0.0.0
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isanboot/lib/libpal_cpa.so.0
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isanboot/lib/libpal_cpa.so
;;
$CARD_INDEX_MOFF_GIDEON | $CARD_INDEX_AXE_WOVES )
;;
*)
#setup_n9k_cpa $card_index
;;
esac
}
setup_cpa_sup_isan() {
local card_index=$1
case $card_index in
$CARD_INDEX_THE_CHILD_RP_1 | $CARD_INDEX_CHURCHILL )
#setup_xr_cpa $card_index
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isan/lib/libpal_cpa.so.0.0.0
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isan/lib/libpal_cpa.so.0
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isan/lib/libpal_cpa.so
;;
$CARD_INDEX_MOFF_GIDEON | $CARD_INDEX_AXE_WOVES )
;;
*)
setup_n9k_cpa $card_index
;;
esac
}
setup_cpa_sup_isan_bootlinks() {
local card_index=$1
case $card_index in
$CARD_INDEX_THE_CHILD_RP_1 | $CARD_INDEX_CHURCHILL )
#setup_xr_cpa $card_index
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isanboot/lib/libpal_cpa.so.0.0.0
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isanboot/lib/libpal_cpa.so.0
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isanboot/lib/libpal_cpa.so
;;
$CARD_INDEX_MOFF_GIDEON | $CARD_INDEX_AXE_WOVES )
;;
*)
;;
esac
}
setup_cpa_lc() {
local card_index=$1
case $card_index in
$CARD_INDEX_THE_CHILD_RP_1 )
;;
$CARD_INDEX_MOFF_GIDEON )
setup_xr_cpa $card_index
;;
*)
setup_n9k_cpa_tor_lc $card_index
;;
esac
}
setup_cpa_tor_lc() {
local card_index=$1
case $card_index in
$CARD_INDEX_CHURCHILL )
setup_xr_cpa_tor_lc $card_index
;;
$CARD_INDEX_THE_CHILD_RP_1 |$CARD_INDEX_MOFF_GIDEON | $CARD_INDEX_AXE_WOVES )
;;
*)
setup_n9k_cpa_tor_lc $card_index
;;
esac
}
/bin/prepare-mfg.sh¶
#!/bin/bash
. /etc/isim_include
if [ -z $1 ]; then
echo "No image?"
echo "Usage: prepare-mfg.sh <image> "
echo "image should be in bootflash, do not give /bootflash/<image>"
exit
else
if [ ! -f /bootflash/$1 ]; then
echo "Cant find image"
exit
fi
fi
usr=`id -un `
if [ $usr == "root" ]; then
echo "Preparing to erase all config"
rm -rf /bootflash/isim.conf
touch /mnt/pss/.clean
touch /mnt/cfg/0/clean-config
touch /mnt/cfg/1/clean-config
#rm -rf /mnt/ifc/cfg/db/*
echo "Cleanup cores"
rm -rf /logflash/core/*
rm -rf /logflash/log/*
rm -rf /mnt/pss/logs/*
rm -rf /mnt/ifc/log/*
rm -rf /recovery/*
echo "Setting up recovery image wait 30 seconds"
cp /bootflash/$1 /recovery
sync
sleep 30
sync
rm -rf /bootflash/*
cp /recovery/$1 /bootflash
sync
sleep 30
sync
echo "Setting up boot variables"
touch /mnt/cfg/0/boot/grub/menu.lst.local
touch /mnt/cfg/1/boot/grub/menu.lst.local
echo "boot $1" > /mnt/cfg/0/boot/grub/menu.lst.local
echo "boot $1" > /mnt/cfg/1/boot/grub/menu.lst.local
touch /mnt/cfg/0/boot/grub/menu.lst.recovery
touch /mnt/cfg/1/boot/grub/menu.lst.recovery
echo "boot $1" > /mnt/cfg/0/boot/grub/menu.lst.recovery
echo "boot $1" > /mnt/cfg/1/boot/grub/menu.lst.recovery
else
bg_action /tmp/prepare-mfg $1
fi