add blank dhcpd.conf for all configurations
[debian6500.git] / master / opt / script / configure_matrix
CommitLineData
b3f3562f
OL
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
1dbdd420
LM
11# get matrix ip
12set ip ""
13set fid [open "/etc/hosts" r]
14while { [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}
26close $fid
27set matrix [join $ip "."]
28
b3f3562f
OL
29spawn /opt/trc6500/tools/matrix_tool
30
31set timeout 3
32
33exec ifconfig eth1:0 192.168.1.1 netmask 255.255.255.0
34
35proc cleanexit {rc} {
36 exec ifconfig eth1:0 down
37 exit $rc
38}
39
40expect {
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}
45expect {
46 "timeout detected" { send_user "can't connect on defaut ip\n"; cleanexit 1 }
47 "taper la commande choisie" { send "10\r" }
48}
49
1dbdd420 50expect "nouvelle adresse" { send "$matrix\r" }
b3f3562f
OL
51
52expect "taper la commande choisie" { send "12\r" }
53
54expect "taper la commande choisie" { send "14\r" }
55
56cleanexit 0
57# vim:set tabstop=4 expandtab shiftwidth=4: