File: reboot-netfinity

package info (click to toggle)
conmux 0.12.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 372 kB
  • sloc: exp: 1,772; perl: 1,361; python: 202; sh: 124; makefile: 52
file content (98 lines) | stat: -rwxr-xr-x 2,329 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/expect -f
#
# reboot-netfinity -- reboot netfinity machines via their management port
#
# This expect script reboots a machine via a managemant port. 
# It only works with the Netfinity-style Service Processors. 
# They have a number-driven interface
#
# example machines: Netfinity 6000R, 8500R
#                   xSeries x350, x370
#
# usage:
#  reboot-netfinity <user> <password> <connect command> ...
#
# examples:
#  reboot-netfinity USERID PASSW0RD telnet 1.2.3.4 7033 
#
# (C) Copyright IBM Corp. 2004, 2005, 2006
# Author: Dave Hansen <haveblue@us.ibm.com>
#
# The Console Multiplexor is released under the GNU Public License V2
#
set P "reboot-netfinity"

if {[llength $argv] < 2} {
	puts stderr "Usage: $P <userid> <password> <cmd> ..."
	exit 1
}
set argc [llength $argv]
set userid [lindex $argv 0]
set password [lindex $argv 1]
set timeout 30 
set send_slow {1 .1}

set command [lrange $argv 2 end]

puts "$P: Logging into service processor with command \"$command\" to restart it";

eval spawn [lrange $argv 2 end]

send -s -- "\033\033\033\033\033" 
expect *;
send "\033"

expect {
	#Log in
	 "USER ID:" {
		send -s -- "$userid\r"
		expect -exact "PASSWORD:"
		send -s -- "$password\r"
		exp_continue;
	}
	#Some machines use different login prompts
	"User_id:" {
		send -s -- "$userid\r"
		expect -exact "Password:"
		send -s -- "$password\r"
		exp_continue;
	}
	#already logged in
	"Z - Start Remote Video" {
		send "6"
		expect -exact "4 - Power On"
		send "3"
		expect -exact "2 - Power Off Immediately"
		send "2"
		expect -exact "0 - Write"
		send "0"
		expect -exact "6.3.2: Write"
		
		send -s -- "\033\033\033\033\033"
		expect -exact "Z - Start Remote Video"
		send "6"
		expect -exact "4 - Power On"
		send "4"
		expect -exact "2 - Power On Release CPU's Reset"
		send "2"
		expect -exact "0 - Write"
		send "0"
		expect -exact "6.4.2: Write"

		# On kernels with ACPI support, the above may send an ACPI
		# event to the OS to perform a clean shutdown.  If that happens
		# we may not ever come back up.  Add the reboot command below
		# to finish the job.
		send -s -- "\033\033\033\033\033"
		expect -exact "Z - Start Remote Video"
		send "7"
		expect -exact "4 - Restart SP"
		send "2"
		expect -exact "0 - Write"
		send "0"
		expect -exact "7.2: Write"
	}

}

puts "$P: reboot initiated"