Debian Codegraph @

drivers/reboot-netfinity

raw
1 #!/usr/bin/expect -f
2 #
3 # reboot-netfinity -- reboot netfinity machines via their management port
4 #
5 # This expect script reboots a machine via a managemant port.
6 # It only works with the Netfinity-style Service Processors.
7 # They have a number-driven interface
8 #
9 # example machines: Netfinity 6000R, 8500R
10 # xSeries x350, x370
11 #
12 # usage:
13 # reboot-netfinity <user> <password> <connect command> ...
14 #
15 # examples:
16 # reboot-netfinity USERID PASSW0RD telnet 1.2.3.4 7033
17 #
18 # (C) Copyright IBM Corp. 2004, 2005, 2006
19 # Author: Dave Hansen <[email protected]>
20 #
21 # The Console Multiplexor is released under the GNU Public License V2
22 #
23 set P "reboot-netfinity"
24
25 if {[llength $argv] < 2} {
26 puts stderr "Usage: $P <userid> <password> <cmd> ..."
27 exit 1
28 }
29 set argc [llength $argv]
30 set userid [lindex $argv 0]
31 set password [lindex $argv 1]
32 set timeout 30
33 set send_slow {1 .1}
34
35 set command [lrange $argv 2 end]
36
37 puts "$P: Logging into service processor with command \"$command\" to restart it";
38
39 eval spawn [lrange $argv 2 end]
40
41 send -s -- "\033\033\033\033\033"
42 expect *;
43 send "\033"
44
45 expect {
46 #Log in
47 "USER ID:" {
48 send -s -- "$userid\r"
49 expect -exact "PASSWORD:"
50 send -s -- "$password\r"
51 exp_continue;
52 }
53 #Some machines use different login prompts
54 "User_id:" {
55 send -s -- "$userid\r"
56 expect -exact "Password:"
57 send -s -- "$password\r"
58 exp_continue;
59 }
60 #already logged in
61 "Z - Start Remote Video" {
62 send "6"
63 expect -exact "4 - Power On"
64 send "3"
65 expect -exact "2 - Power Off Immediately"
66 send "2"
67 expect -exact "0 - Write"
68 send "0"
69 expect -exact "6.3.2: Write"
70
71 send -s -- "\033\033\033\033\033"
72 expect -exact "Z - Start Remote Video"
73 send "6"
74 expect -exact "4 - Power On"
75 send "4"
76 expect -exact "2 - Power On Release CPU's Reset"
77 send "2"
78 expect -exact "0 - Write"
79 send "0"
80 expect -exact "6.4.2: Write"
81
82 # On kernels with ACPI support, the above may send an ACPI
83 # event to the OS to perform a clean shutdown. If that happens
84 # we may not ever come back up. Add the reboot command below
85 # to finish the job.
86 send -s -- "\033\033\033\033\033"
87 expect -exact "Z - Start Remote Video"
88 send "7"
89 expect -exact "4 - Restart SP"
90 send "2"
91 expect -exact "0 - Write"
92 send "0"
93 expect -exact "7.2: Write"
94 }
95
96 }
97
98 puts "$P: reboot initiated"