virt.virt_test_utils: run_autotest - 'tar' needs relative paths to strip the leading '/'
[autotest-zwu.git] / conmux / helpers / autoboot-helper
blobe147fc8256fd950750f18178f5de8b925ae5989d
1 #! /usr/bin/expect
3 # autoboot-helper -- automatic boot helper
5 # Some machines have real issues rebooting.  This helper watches their
6 # console output for the telltale signs of a reboot in progress.  When
7 # spotted this triggers an automated 'manual' hardreset.  For use when
8 # machines fail to reboot at the BIOS level.
10 # (C) Copyright IBM Corp. 2004, 2005, 2006
11 # Author: Andy Whitcroft <andyw@uk.ibm.com>
13 # The Console Multiplexor is released under the GNU Public License V2
15 set P "autoboot-numaq"
16 log_user 0
18 if {$argc != 0} {
19         puts stderr "Usage: $P"
20         exit 1
23 proc note {msg} {
24         global P
25         puts stderr "$P: $msg"
27 proc warn {msg} {
28         global P
29         puts stderr "$P: $msg"
30         puts "~\$msg $msg"
33 set timeout -1
34 set likely 0
35 expect_user {
36         {TEST;} {
37                 warn "test trigger detected"
38                 exp_continue
39         }
40         {Unmounting file systems} {
41                 note "controlled reboot in progress ..."
42                 set likely [clock seconds]
43                 exp_continue
44         }
45         {Unmounting local filesystems...} {
46                 note "controlled reboot in progress ..."
47                 set likely [clock seconds]
48                 exp_continue
49         }
50         -ex {***** REBOOT LINUX *****} {
51                 note "fsck failure occured ..."
52                 set likely [clock seconds]
53                 exp_continue
54         }
55         {Restarting system.} {
56                 if {$likely != 0} {
57                         warn "shutdown complete, restart indicated"
58                         puts "~\$hardreset"
59                         set likely 0
60                 } else {
61                         warn "likely false positive"
62                 }
63                 exp_continue
64         }
65         "*\n" {
66                 if {$likely > 0 && ([clock seconds] - $likely) > 60} {
67                         warn "trigger timeout"
68                         set likely 0
69                 }
70                 exp_continue
71         }