Skip to content

Instantly share code, notes, and snippets.

@faxm0dem
Created February 19, 2020 07:53
Show Gist options
  • Save faxm0dem/d026d9e0c6178eb6c8e23a51f0012903 to your computer and use it in GitHub Desktop.
Save faxm0dem/d026d9e0c6178eb6c8e23a51f0012903 to your computer and use it in GitHub Desktop.
conserver ILOM
#!/usr/bin/expect -f
#
# script for SUN ILOM on x4x00 series
# tested on ILOM 1.0.3
# this will probably be obsoleted in future revisions
# when ipmi 2.0 SOL will be supported on these boxes
# connects to $username@$ilom
# and starts SOL command
# Also checks for Terminated Serial command
# To re-init SOL connection on ILOM
# either down/up console or use "Esc ("
# send fixes/improvements to
# [email protected]
#
set DEBUG 0
set ilom [lindex $argv 0]
regsub "^cc" $ilom "sp" ilom
set username "conserver"
set password "changeme"
set cmdline "start -script /SP/console"
set prompt "^.*-> $"
set respawn "Serial console stopped."
set timeout 60
spawn /usr/bin/ssh -e\[ $username@$ilom.sp
match_max 10000
expect {
# before ssh session
-re "The authenticity of host .* be established\.\r
RSA key fingerprint is.*\.\r
Are you sure you want to continue connecting \\(yes/no\\)\\? " { send -- "yes\r"; exp_continue }
# cli session starts
-re ".*assword: " {
send "$password\r"
expect -re $prompt
send -- "$cmdline\r"
expect {
-exact "Serial console is in use." {
if ($DEBUG) { puts "EXPECT info: Serial console is in use" }
send -- "stop -script /SP/console\r"
if ($DEBUG) { puts "EXPECT info: Stopped console instance" }
sleep 5
exp_continue
}
-re $prompt {
sleep 5
send -- "$cmdline\r"
exp_continue
}
-exact "Serial console started. To stop, type ESC (" {
interact {
# -o
# -exact $respawn {
# if ($DEBUG) { puts "EXPECT info: Serial console has been terminated somehow." }
# sleep 5
# send -- "$cmdline\r"
# }
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment