
#!/bin/sh
#
#    Copyright (c) 2009 Brocade Communications Systems, Inc.
#    All rights reserved.
#
#    Description:
#	This script append the IP addresses for the BP blades
#	to the /etc/hosts.
#
#

PATH=/bin:/usr/bin:/sbin:/usr/sbin

cp /mnt/etc/hosts /etc/hosts

# for consistentsy, hostname is set using existing sysname()
source /etc/init.d/functions
hostname $(sysname "#sw0" < /etc/hosts)

# This is for Defect 237999 to update /etc/hosts on the Standby
# when IpaddrSet is issued on the Active CP.
cp /mnt/etc/hosts /etc/hosts

# 262238: scan /etc/hosts for latest switchname and set hostname
# for consistentsy, hostname is set using existing sysname()
source /etc/init.d/functions
hostname $(sysname "#sw0" < /etc/hosts)

# Grep for the latest addition (IP address or internal name)
# in the current release for the /etc/hosts to be updated properly.

grep "spear_dpf" /mnt/etc/hosts > /dev/null 2>&1
h1=$?
if [ $h1 -ne 0 ]; then
sed /cp_1_inteth/q /mnt/etc/hosts > /mnt/etc/hosts.new
echo "
127.1.1.5		cp4_eth1            # cp0 internal for pluto
127.1.1.6		cp5_eth1            # cp1 internal for pluto
127.1.2.14		cp4_eth3            # cp0 internal for pluto
127.1.2.15		cp5_eth3            # cp1 internal for pluto
127.1.14.40		cp4_cocp_eth2       # cocp0 internal for pluto
127.1.15.50		cp5_cocp_eth2       # cocp1 internal for pluto

127.1.1.7		cp6_eth1            # cp0 internal for netpune
127.1.1.8		cp7_eth1            # cp1 internal for neptune
127.1.2.16		cp6_eth3            # cp0 internal for neptune
127.1.2.17		cp7_eth3            # cp1 internal for neptune
127.1.16.60		cp6_cocp_eth2       # cocp0 internal for neptune
127.1.17.70		cp7_cocp_eth2       # cocp1 internal for neptune

127.1.14.2		cp4_s1              #cp6_slot1 for cp in pluto slot4
127.1.14.3		cp4_s2              #cp6_slot2 for cp in pluto slot4
127.1.14.4		cp4_s3              #cp6_slot3 for cp in pluto slot4
127.1.14.5		cp4_s4              #cp6_slot4 for cp in pluto slot4
127.1.14.6		cp4_s5              #cp6_slot5 for cp in pluto slot4
127.1.14.7		cp4_s6              #cp6_slot6 for cp in pluto slot4
127.1.14.8		cp4_s7              #cp6_slot7 for cp in pluto slot4
127.1.14.9		cp4_s8              #cp6_slot8 for cp in pluto slot4

127.1.15.2		cp5_s1              #cp7_slot1 for cp in pluto slot5
127.1.15.3		cp5_s2              #cp7_slot2 for cp in pluto slot5
127.1.15.4		cp5_s3              #cp7_slot3 for cp in pluto slot5
127.1.15.5		cp5_s4              #cp7_slot4 for cp in pluto slot5
127.1.15.6		cp5_s5              #cp7_slot5 for cp in pluto slot5
127.1.15.7		cp5_s6              #cp7_slot6 for cp in pluto slot5
127.1.15.8		cp5_s7              #cp7_slot7 for cp in pluto slot5
127.1.15.9		cp5_s8              #cp7_slot8 for cp in pluto slot5

127.1.16.2		cp6_s1              #cp6_slot1 for cp in Neptune slot 6
127.1.16.3		cp6_s2              #cp6_slot2 for cp in Neptune slot 6
127.1.16.4		cp6_s3              #cp6_slot3 for cp in Neptune slot 6
127.1.16.5		cp6_s4              #cp6_slot4 for cp in Neptune slot 6
127.1.16.6		cp6_s5              #cp6_slot5 for cp in Neptune slot 6
127.1.16.7		cp6_s6              #cp6_slot6 for cp in Neptune slot 6
127.1.16.8		cp6_s7              #cp6_slot7 for cp in Neptune slot 6
127.1.16.9		cp6_s8              #cp6_slot8 for cp in Neptune slot 6
127.1.16.10		cp6_s9              #cp6_slot9 for cp in Neptune slot 6
127.1.16.11		cp6_s10             #cp6_slot10 for cp in Neptune slot 6
127.1.16.12		cp6_s11             #cp6_slot11 for cp in Neptune slot 6
127.1.16.13		cp6_s12             #cp6_slot12 for cp in Neptune slot 6
127.1.16.14		cp6_s13             #cp6_slot13 for cp in Neptune slot 6
127.1.16.15		cp6_s14             #cp6_slot14 for cp in Neptune slot 6
127.1.16.16		cp6_s15             #cp6_slot15 for cp in Neptune slot 6
127.1.16.17		cp6_s16             #cp6_slot16 for cp in Neptune slot 6

127.1.17.2		cp7_s1              #cp7_slot1 for cp in Neptune slot7
127.1.17.3		cp7_s2              #cp7_slot2 for cp in Neptune slot7
127.1.17.4		cp7_s3              #cp7_slot3 for cp in Neptune slot7
127.1.17.5		cp7_s4              #cp7_slot4 for cp in Neptune slot7
127.1.17.6		cp7_s5              #cp7_slot5 for cp in Neptune slot7
127.1.17.7		cp7_s6              #cp7_slot6 for cp in Neptune slot7
127.1.17.8		cp7_s7              #cp7_slot7 for cp in Neptune slot7
127.1.17.9		cp7_s8              #cp7_slot8 for cp in Neptune slot7
127.1.17.10		cp7_s9              #cp7_slot9 for cp in Neptune slot7
127.1.17.11		cp7_s10             #cp7_slot10 for cp in Neptune slot7
127.1.17.12		cp7_s11             #cp7_slot11 for cp in Neptune slot7
127.1.17.13		cp7_s12             #cp7_slot12 for cp in Neptune slot7
127.1.17.14		cp7_s13             #cp7_slot13 for cp in Neptune slot7
127.1.17.15		cp7_s14             #cp7_slot14 for cp in Neptune slot7
127.1.17.16		cp7_s15             #cp7_slot15 for cp in Neptune slot7
127.1.17.17		cp7_s16             #cp7_slot16 for cp in Neptune slot7

127.1.10.1		sprint_bp           #sprint_bp
127.1.10.10		spear_cpf           #FCIP cp
127.1.10.21		spear_dpf           #FCIP dp" >> /mnt/etc/hosts.new
mv /mnt/etc/hosts.new /mnt/etc/hosts
fi
