5 # ============================================================================
7 # Copyright (C) THALES. All rights reserved
8 # Author: Laurent Mazet
10 # 2013-11-10 V1.0 : Creation
12 # 2013-11-20 V1.1 : L.Mazet ajout possibilite de configuration du switch
14 # ============================================================================
19 TRC6500_SCRIPT_DIR
=$
(dirname $0)
24 echo "usage: $PROGNAME [-a] [-d] [-h] [-i <id>]"
25 echo " -a: configure all boards"
27 echo " -h: help message"
28 echo " -i: board id (from 1 to 5)"
34 function title
() { echo -e "\033[0;1m$*\033[0;0m"; }
35 function pass
() { echo -e "\033[1;32m$*\033[0;0m"; }
36 function warn
() { echo -e "\033[1;33m$*\033[0;0m"; }
37 function fail
() { echo -e "\033[1;31m$*\033[0;0m"; }
39 # configuration values
43 while [ $# -gt 0 ]; do
54 # switch port configure function ()
56 function sw_configure
() {
58 off
) CMD
="-c 'configure terminal' -c 'interface range g1/39-44' -c 'shutdown' -c end -c 'clear mac address-table dynamic' -c 'clear ip arp inspection log' -c exit";;
59 on
) CMD
="-c 'configure terminal' -c 'interface range g1/39-44' -c 'no shutdown' -c end -c exit";;
60 1) CMD
="-c 'configure terminal' -c 'interface g1/39' -c 'no shutdown' -c end -c exit";;
61 2) CMD
="-c 'configure terminal' -c 'interface g1/40' -c 'no shutdown' -c end -c exit";;
62 3) CMD
="-c 'configure terminal' -c 'interface g1/41' -c 'no shutdown' -c end -c exit";;
63 4) CMD
="-c 'configure terminal' -c 'interface g1/42' -c 'no shutdown' -c end -c exit";;
64 5) CMD
="-c 'configure terminal' -c 'interface g1/43' -c 'no shutdown' -c end -c exit";;
65 6) CMD
="-c 'configure terminal' -c 'interface g1/44' -c 'no shutdown' -c end -c exit";;
68 if [ "$DRY" = "yes" ]; then
69 echo connect_switch
-h swm
$CMD
71 LOG
=/tmp
/$PROGNAME-$$.log
72 echo -n "sw_configure $1: "
73 eval $TRC6500_SCRIPT_DIR/connect_switch
$CMD swm
>&$LOG && pass OK ||
{ fail KO
; cat $LOG; exit 1; }
79 1) CH1
=0; CH2
=1; CLOCKREF
=external
;;
80 2) CH1
=2; CH2
=3; CLOCKREF
=internal
;;
81 3) CH1
=4; CH2
=5; CLOCKREF
=internal
;;
82 4) CH1
=6; CH2
=7; CLOCKREF
=internal
;;
83 5) CH1
=8; CH2
=9; CLOCKREF
=internal
;;
84 6) CH1
=10; CH2
=11; CLOCKREF
=internal
;;
86 for id
in $
(seq 1 5); do
87 title
"switch off all fe306 ports"
89 title
"switch on port for fe306 $id"
91 title
"configure fe306 $id"
92 if [ "$DRY" = "yes" ]; then
93 echo $
(basename $0) -i $id
95 { $0 -i $id | mawk
-W interactive
'{print " " $0}'; } && pass OK ||
{ fail KO
; exit 1; }
98 title
"switch on all fe306 ports"
102 *) echo "unknown fe306 id ($ID)"; exit 1;;
107 function configure
() {
108 echo -n "$1 [$2 <= $3]: "
109 if [ "$DRY" = "yes" ]; then
110 echo wget
-q -O - http
://$IP/$1?
$2=$3
112 wget
-q -O - http
://$IP/$1?
$2=$3 >/dev
/null
&& pass OK ||
{ fail KO
; exit 1; }
116 # setup local address
118 title
"setup local address"
119 cmd
="ifconfig eth1:1 192.168.0.2 netmask 255.255.255.0"
120 [ "$DRY" = "yes" ] && echo $cmd ||
{ echo -n $cmd" "; eval $cmd && pass OK ||
{ fail KO
; exit 1; }; }
122 # check if fe306 is connected
124 #title "check presence of $IP"
125 #cmd="ping -c 1 -w 10 -W 10 $IP"
126 #[ "$DRY" = "yes" ] && echo $cmd || { echo -n $cmd" "; eval $cmd >&/dev/null && pass OK || { warn KO; ifconfig eth1:1 down; exit 0; }; }
130 [ "$DRY" = "yes" ] && SN
=00 || \
131 SN
=$
(wget
-q -O - http
://$IP/versions_en.html | mawk
'/MODULE/ { module = 1 } /Serial Number/ { if (module) { printf "%02X", $4; exit 0 } }')
133 [[ "$SN" =~ ^
[0-9A-F][0-9A-F]$
]] ||
{ echo "unknown serial number ($SN)"; exit 1; }
139 configure ModeServ.cmd serv_mode MANUAL
140 configure MacServ.cmd serv_mac
00.80.EE
.00.
$SN.01
141 configure IpServ.cmd serv_ip $
(getent hosts |
awk '/fe306-'$ID'/ {print $1}')
142 configure MaskServ.cmd serv_mask
255.255.255.0
144 for i
in $
(seq 1 8); do
145 configure MacProd
$i.cmd prod_mac
$i 00.80.EE
.00.
$SN.0$
((i
+1))
146 configure IpProd
$i.cmd prod_ip
$i 10.133.26.1$ID$i
149 configure IpMulticast.cmd multicast_ip
238.0.0.0
150 configure RxMulticast.cmd multicast_rx
62002
151 configure TxMulticast.cmd multicast_tx
62004
152 configure TTL.cmd ttl
10
156 title
"configure gps"
158 configure GpsRate.cmd gps_rate
19200
159 configure GpsChar.cmd gps_char
8
160 configure GpsStop.cmd gps_stop
1
161 configure GpsParity.cmd gps_parity no
163 # configure miscellaneous
165 title
"configure miscellaneous"
166 configure BoardNum.cmd board_num
$ID
167 configure RackNum.cmd rack_num
1
168 configure Chan1Num.cmd channel1_num
$CH1
169 configure Chan2Num.cmd channel2_num
$CH2
171 configure FpgaLoc.cmd fpga_loc FLASH
172 configure Clk10Mhz.cmd clk_10
$CLOCKREF
173 configure PllConfig.cmd pll_cfg pll_cfg_02
175 # unset local address
177 title
"unset local address"
178 cmd
="ifconfig eth1:1 down"
179 [ "$DRY" = "yes" ] && echo $cmd ||
{ echo -n $cmd" "; eval $cmd && pass OK ||
{ fail KO
; exit 1; }; }
181 # vim:set tabstop=4 shiftwidth=4 softtabstop=4: