add blank dhcpd.conf for all configurations
[debian6500.git] / master / opt / script / configure_matrix
1 #!/usr/bin/expect
2
3 # ============================================================================
4 #
5 # Copyright (C) THALES. All rights reserved
6 #
7 # * V1.0 Laurent Mazet 29/04/2013
8 # creation script de configuration de la matrice par ligne de commande
9 # ============================================================================
10
11 # get matrix ip
12 set ip ""
13 set fid [open "/etc/hosts" r]
14 while { [gets $fid line] >= 0 } {
15 regsub "#.*$" $line {} line
16 if {[string match "*matrix*" $line]} {
17 regsub -all "\\." $line " " line
18 foreach word $line {
19 if {![regexp "^\[0-9\]+$" $word]} break
20 set digit [format "%03d" $word]
21 set ip [concat $ip $digit]
22 }
23 break
24 }
25 }
26 close $fid
27 set matrix [join $ip "."]
28
29 spawn /opt/trc6500/tools/matrix_tool
30
31 set timeout 3
32
33 exec ifconfig eth1:0 192.168.1.1 netmask 255.255.255.0
34
35 proc cleanexit {rc} {
36 exec ifconfig eth1:0 down
37 exit $rc
38 }
39
40 expect {
41 "taper la commande choisie" { send "0\r" }
42 timeout { send_user "connection to $host timed out\n"; cleanexit 1 }
43 eof { send_user "connection to host failed\n"; cleanexit 1 }
44 }
45 expect {
46 "timeout detected" { send_user "can't connect on defaut ip\n"; cleanexit 1 }
47 "taper la commande choisie" { send "10\r" }
48 }
49
50 expect "nouvelle adresse" { send "$matrix\r" }
51
52 expect "taper la commande choisie" { send "12\r" }
53
54 expect "taper la commande choisie" { send "14\r" }
55
56 cleanexit 0
57 # vim:set tabstop=4 expandtab shiftwidth=4: