Added scripts from lgcore
[debian6500.git] / simple-cdd / additional_scripts / configure_switch_bootstrap.tcl
CommitLineData
b3f3562f
OL
1#!/usr/bin/expect
2
3set host [lrange $argv 0 0]
4if { $host == "" } {
5 puts "usage: configure_switch_bootstrap.tcl \[swg1|swg2|swm\]"
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" }
13if { $ipaddress == "" } { puts "unknown switch '$host'""; exit 1 }
14
15spawn screen -c . /dev/ttyUSB0
16
17set timeout 5
18
19set state 0
20while { $state != 1 } {
21 expect {
22 timeout { send "\r" }
23 -exact ">" { send "enable\r" }
24 "#" { set state 1 }
25 "Password:" { send "thales\r" }
26 eof { send_user "connection to host failed\n"; exit 1 }
27 }
28}
29
30send "configure terminal\r"
31expect "#" { send "interface vlan 1\r" }
32expect "#" { send "ip address $ipaddress 255.255.255.0\r" }
33expect "#" { send "exit\r" }
34expect "#" { send "line vty 0 4\r" }
35expect "#" { send "password thales\r" }
36expect "#" { send "enable password thales\r" }
37expect "#" { send "end\r" }
38
39# quit switch connection
40expect "#" { send "exit\r" }
41
42# to quit screen we need to send C-a \.
43send "\001\\"
44expect "kill all your windows" { send "y\r" }
45
46exit 0
47# vim:set tabstop=4 expandtab shiftwidth=4: