add a script to color log
[debian6500.git] / master / opt / script / configure_switch_bootstrap
CommitLineData
b3f3562f
OL
1#!/usr/bin/expect
2
3set host [lrange $argv 0 0]
4if { $host == "" } {
757c2d98 5 puts "usage: configure_switch_bootstrap \[sw1|sw2|swg1|swg2|swm\]"
b3f3562f
OL
6 exit 1
7}
8
9set ipaddress ""
10if { $host == "swg1" } { set ipaddress "10.133.26.231" }
11if { $host == "swg2" } { set ipaddress "10.133.26.232" }
12if { $host == "swm" } { set ipaddress "10.133.28.231" }
8a1c6cff
OL
13if { $host == "sw1" } { set ipaddress "10.133.26.231" }
14if { $host == "sw2" } { set ipaddress "10.133.26.232" }
a991c7ba 15if { $host == "sw" } { set ipaddress "10.133.26.231" }
b3f3562f
OL
16if { $ipaddress == "" } { puts "unknown switch '$host'""; exit 1 }
17
18spawn screen -c . /dev/ttyUSB0
19
20set timeout 5
21
22set state 0
23while { $state != 1 } {
24 expect {
25 timeout { send "\r" }
26 -exact ">" { send "enable\r" }
27 "#" { set state 1 }
28 "Password:" { send "thales\r" }
29 eof { send_user "connection to host failed\n"; exit 1 }
30 }
31}
32
33send "configure terminal\r"
34expect "#" { send "interface vlan 1\r" }
35expect "#" { send "ip address $ipaddress 255.255.255.0\r" }
36expect "#" { send "exit\r" }
37expect "#" { send "line vty 0 4\r" }
38expect "#" { send "password thales\r" }
39expect "#" { send "enable password thales\r" }
40expect "#" { send "end\r" }
41
42# quit switch connection
43expect "#" { send "exit\r" }
44
45# to quit screen we need to send C-a \.
46send "\001\\"
47expect "kill all your windows" { send "y\r" }
48
49exit 0
50# vim:set tabstop=4 expandtab shiftwidth=4: