X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=master%2Fopt%2Fscript%2Fconfigure_switch_bootstrap.tcl;fp=master%2Fopt%2Fscript%2Fconfigure_switch_bootstrap.tcl;h=db95d4d673f87fd5c731098ed8522737da277649;hb=84523910649b50272f5a8693bf7c5cdb73ad1353;hp=0000000000000000000000000000000000000000;hpb=f81c83b65ada3bc612e87705f15860934f2f5a6d;p=debian6500.git diff --git a/master/opt/script/configure_switch_bootstrap.tcl b/master/opt/script/configure_switch_bootstrap.tcl new file mode 100755 index 0000000..db95d4d --- /dev/null +++ b/master/opt/script/configure_switch_bootstrap.tcl @@ -0,0 +1,49 @@ +#!/usr/bin/expect + +set host [lrange $argv 0 0] +if { $host == "" } { + puts "usage: configure_switch_bootstrap.tcl \[sw1|sw2|swg1|swg2|swm\]" + exit 1 +} + +set ipaddress "" +if { $host == "swg1" } { set ipaddress "10.133.26.231" } +if { $host == "swg2" } { set ipaddress "10.133.26.232" } +if { $host == "swm" } { set ipaddress "10.133.28.231" } +if { $host == "sw1" } { set ipaddress "10.133.26.231" } +if { $host == "sw2" } { set ipaddress "10.133.26.232" } +if { $ipaddress == "" } { puts "unknown switch '$host'""; exit 1 } + +spawn screen -c . /dev/ttyUSB0 + +set timeout 5 + +set state 0 +while { $state != 1 } { + expect { + timeout { send "\r" } + -exact ">" { send "enable\r" } + "#" { set state 1 } + "Password:" { send "thales\r" } + eof { send_user "connection to host failed\n"; exit 1 } + } +} + +send "configure terminal\r" +expect "#" { send "interface vlan 1\r" } +expect "#" { send "ip address $ipaddress 255.255.255.0\r" } +expect "#" { send "exit\r" } +expect "#" { send "line vty 0 4\r" } +expect "#" { send "password thales\r" } +expect "#" { send "enable password thales\r" } +expect "#" { send "end\r" } + +# quit switch connection +expect "#" { send "exit\r" } + +# to quit screen we need to send C-a \. +send "\001\\" +expect "kill all your windows" { send "y\r" } + +exit 0 +# vim:set tabstop=4 expandtab shiftwidth=4: