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=/opt/trc6500/script
20 TRC6500_SCRIPT_DIR
=$
(dirname $0)
25 echo "usage: $PROGNAME [-a] [-d] [-h] [-i <id>]"
26 echo " -a: configure all boards"
28 echo " -h: help message"
29 echo " -i: board id (from 1 to 5)"
35 function title
() { echo -e "\033[0;1m$*\033[0;0m"; }
36 function pass
() { echo -e "\033[1;32m$*\033[0;0m"; }
37 function warn
() { echo -e "\033[1;33m$*\033[0;0m"; }
38 function fail
() { echo -e "\033[1;31m$*\033[0;0m"; }
40 # configuration values
44 while [ $# -gt 0 ]; do
55 # switch port configure function ()
57 function sw_configure
() {
59 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";;
60 on
) CMD
="-c 'configure terminal' -c 'interface range g1/39-44' -c 'no shutdown' -c end -c exit";;
61 1) CMD
="-c 'configure terminal' -c 'interface g1/39' -c 'no shutdown' -c end -c exit";;
62 2) CMD
="-c 'configure terminal' -c 'interface g1/40' -c 'no shutdown' -c end -c exit";;
63 3) CMD
="-c 'configure terminal' -c 'interface g1/41' -c 'no shutdown' -c end -c exit";;
64 4) CMD
="-c 'configure terminal' -c 'interface g1/42' -c 'no shutdown' -c end -c exit";;
65 5) CMD
="-c 'configure terminal' -c 'interface g1/43' -c 'no shutdown' -c end -c exit";;
66 6) CMD
="-c 'configure terminal' -c 'interface g1/44' -c 'no shutdown' -c end -c exit";;
69 if [ "$DRY" = "yes" ]; then
70 echo connect_switch.tcl
-h swm
$CMD
72 LOG
=/tmp
/$PROGNAME-$$.log
73 echo -n "sw_configure $1: "
74 eval $TRC6500_SCRIPT_DIR/connect_switch.tcl
$CMD swm
>&$LOG && pass OK ||
{ fail KO
; cat $LOG; exit 1; }
80 1) CH1
=0; CH2
=1; CLOCKREF
=external
;;
81 2) CH1
=2; CH2
=3; CLOCKREF
=internal
;;
82 3) CH1
=4; CH2
=5; CLOCKREF
=internal
;;
83 4) CH1
=6; CH2
=7; CLOCKREF
=internal
;;
84 5) CH1
=8; CH2
=9; CLOCKREF
=internal
;;
85 6) CH1
=10; CH2
=11; CLOCKREF
=internal
;;
87 for id
in $
(seq 1 5); do
88 title
"switch off all fe306 ports"
90 title
"switch on port for fe306 $id"
92 title
"configure fe306 $id"
93 if [ "$DRY" = "yes" ]; then
94 echo $
(basename $0) -i $id
96 { $0 -i $id | mawk
-W interactive
'{print " " $0}'; } && pass OK ||
{ fail KO
; exit 1; }
99 title
"switch on all fe306 ports"
103 *) echo "unknown fe306 id ($ID)"; exit 1;;
108 function configure
() {
109 echo -n "$1 [$2 <= $3]: "
110 if [ "$DRY" = "yes" ]; then
111 echo wget
-q -O - http
://$IP/$1?
$2=$3
113 wget
-q -O - http
://$IP/$1?
$2=$3 >/dev
/null
&& pass OK ||
{ fail KO
; exit 1; }
117 # setup local address
119 title
"setup local address"
120 cmd
="ifconfig eth1:1 192.168.0.2 netmask 255.255.255.0"
121 [ "$DRY" = "yes" ] && echo $cmd ||
{ echo -n $cmd" "; eval $cmd && pass OK ||
{ fail KO
; exit 1; }; }
123 # check if fe306 is connected
125 #title "check presence of $IP"
126 #cmd="ping -c 1 -w 10 -W 10 $IP"
127 #[ "$DRY" = "yes" ] && echo $cmd || { echo -n $cmd" "; eval $cmd >&/dev/null && pass OK || { warn KO; ifconfig eth1:1 down; exit 0; }; }
131 [ "$DRY" = "yes" ] && SN
=00 || \
132 SN
=$
(wget
-q -O - http
://$IP/versions_en.html | mawk
'/MODULE/ { module = 1 } /Serial Number/ { if (module) { printf "%02X", $4; exit 0 } }')
134 [[ "$SN" =~ ^
[0-9A-F][0-9A-F]$
]] ||
{ echo "unknown serial number ($SN)"; exit 1; }
140 configure ModeServ.cmd serv_mode MANUAL
141 configure MacServ.cmd serv_mac
00.80.EE
.00.
$SN.01
142 configure IpServ.cmd serv_ip
10.133.28.1${ID}0
143 configure MaskServ.cmd serv_mask
255.255.255.0
145 for i
in $
(seq 1 8); do
146 configure MacProd
$i.cmd prod_mac
$i 00.80.EE
.00.
$SN.0$
((i
+1))
147 configure IpProd
$i.cmd prod_ip
$i 10.133.26.1$ID$i
150 configure IpMulticast.cmd multicast_ip
238.0.0.0
151 configure RxMulticast.cmd multicast_rx
62002
152 configure TxMulticast.cmd multicast_tx
62004
153 configure TTL.cmd ttl
10
157 title
"configure gps"
159 configure GpsRate.cmd gps_rate
19200
160 configure GpsChar.cmd gps_char
8
161 configure GpsStop.cmd gps_stop
1
162 configure GpsParity.cmd gps_parity no
164 # configure miscellaneous
166 title
"configure miscellaneous"
167 configure BoardNum.cmd board_num
$ID
168 configure RackNum.cmd rack_num
1
169 configure Chan1Num.cmd channel1_num
$CH1
170 configure Chan2Num.cmd channel2_num
$CH2
172 configure FpgaLoc.cmd fpga_loc FLASH
173 configure Clk10Mhz.cmd clk_10
$CLOCKREF
174 configure PllConfig.cmd pll_cfg pll_cfg_02
176 # unset local address
178 title
"unset local address"
179 cmd
="ifconfig eth1:1 down"
180 [ "$DRY" = "yes" ] && echo $cmd ||
{ echo -n $cmd" "; eval $cmd && pass OK ||
{ fail KO
; exit 1; }; }
182 # vim:set tabstop=4 shiftwidth=4 softtabstop=4: