File: tickle-helper

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 (99 lines) | stat: -rwxr-xr-x 2,008 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
99
#! /usr/bin/expect
#
# tickle-helper -- watch for reboots and 'tickle' the console during them
#
# Some consoles get broken when the machine reboots.  There are normally
# fixed by trying to use them at or arround the reboot.  Watch for reboots
# and initiate use of the console to trigger a drop/reconnect cycle.
#
# (C) Copyright IBM Corp. 2004, 2005, 2006
# Author: Andy Whitcroft <andyw@uk.ibm.com>
#
# The Console Multiplexor is released under the GNU Public License V2
#
set P "tickle-helper"
log_user 0

if {$argc != 0} {
	puts stderr "Usage: $P"
	exit 1
}

proc note {msg} {
	global P
	puts stderr "$P: $msg"
}
proc warn {msg} {
	global P
	puts stderr "$P: $msg"
	puts "~\$msg $msg"
}

proc tickle {} {
	set timeout 5
	warn "tickling console ..."
	puts ""
	set now [clock seconds]
	expect_user {
		{blade: ERROR: console lost} {
		}
		{Elapsed time since release of system processors:} {
		}
		"*\n" {
			if {([clock seconds] - $now) > 5} {
				set now [clock seconds]
				warn "tickling console ..."
				puts ""
			}
			exp_continue
		}
		timeout {
			set now [clock seconds]
			warn "tickling console ..."
			puts ""
			exp_continue
		}
	}
	set timeout -1
	warn "tickle complete ..."
}

set timeout -1
set likely 0
expect_user {
	{TEST;} {
		warn "test trigger detected"
		exp_continue
	}
	-re {Unmounting file systems|Unmounting local filesystems...} {
		note "controlled reboot in progress ..."
		set likely [clock seconds]
		exp_continue
	}
	-ex {***** REBOOT LINUX *****} {
		note "fsck failure occured ..."
		set likely [clock seconds]
		exp_continue
	}
	-re {HARDBOOT INITIATED|initated a hard reset} {
		tickle
		exp_continue
	}
	-re {Please stand by while rebooting the system|Restarting system} {
		if {$likely != 0} {
			warn "shutdown complete, restart indicated"
			tickle
			set likely 0
		} else {
			warn "likely false positive"
		}
		exp_continue
	}
	"*\n" {
		if {$likely > 0 && ([clock seconds] - $likely) > 60} {
			warn "trigger timeout"
			set likely 0
		}
		exp_continue
	}
}