Fixing a missing quote meant to go on r5471
[autotest-zwu.git] / conmux / helpers / tickle-helper
blob2623c5299e28aa3eb2e6eeeb29d1a2a2cced46a9
1 #! /usr/bin/expect
3 # tickle-helper -- watch for reboots and 'tickle' the console during them
5 # Some consoles get broken when the machine reboots.  There are normally
6 # fixed by trying to use them at or arround the reboot.  Watch for reboots
7 # and initiate use of the console to trigger a drop/reconnect cycle.
9 # (C) Copyright IBM Corp. 2004, 2005, 2006
10 # Author: Andy Whitcroft <andyw@uk.ibm.com>
12 # The Console Multiplexor is released under the GNU Public License V2
14 set P "tickle-helper"
15 log_user 0
17 if {$argc != 0} {
18         puts stderr "Usage: $P"
19         exit 1
22 proc note {msg} {
23         global P
24         puts stderr "$P: $msg"
26 proc warn {msg} {
27         global P
28         puts stderr "$P: $msg"
29         puts "~\$msg $msg"
32 proc tickle {} {
33         set timeout 5
34         warn "tickling console ..."
35         puts ""
36         set now [clock seconds]
37         expect_user {
38                 {blade: ERROR: console lost} {
39                 }
40                 {Elapsed time since release of system processors:} {
41                 }
42                 "*\n" {
43                         if {([clock seconds] - $now) > 5} {
44                                 set now [clock seconds]
45                                 warn "tickling console ..."
46                                 puts ""
47                         }
48                         exp_continue
49                 }
50                 timeout {
51                         set now [clock seconds]
52                         warn "tickling console ..."
53                         puts ""
54                         exp_continue
55                 }
56         }
57         set timeout -1
58         warn "tickle complete ..."
61 set timeout -1
62 set likely 0
63 expect_user {
64         {TEST;} {
65                 warn "test trigger detected"
66                 exp_continue
67         }
68         -re {Unmounting file systems|Unmounting local filesystems...} {
69                 note "controlled reboot in progress ..."
70                 set likely [clock seconds]
71                 exp_continue
72         }
73         -ex {***** REBOOT LINUX *****} {
74                 note "fsck failure occured ..."
75                 set likely [clock seconds]
76                 exp_continue
77         }
78         -re {HARDBOOT INITIATED|initated a hard reset} {
79                 tickle
80                 exp_continue
81         }
82         -re {Please stand by while rebooting the system|Restarting system} {
83                 if {$likely != 0} {
84                         warn "shutdown complete, restart indicated"
85                         tickle
86                         set likely 0
87                 } else {
88                         warn "likely false positive"
89                 }
90                 exp_continue
91         }
92         "*\n" {
93                 if {$likely > 0 && ([clock seconds] - $likely) > 60} {
94                         warn "trigger timeout"
95                         set likely 0
96                 }
97                 exp_continue
98         }