aboutsummaryrefslogtreecommitdiff
blob: f7a7851462ceff6c5d7eb3d82e4307cb3baa22d7 (plain)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
API description for shutdown


Almost all code related to shutdown is stored under
/usr/share/vdr/shutdown/

=================
= wakeup-modules:
=================


Wakeup-modules are named wakeup-${NAME}.sh

The used wakeup-module is selected by WAKEUP_METHOD in /etc/conf.d/vdr.shutdown.
Here acpi is used by default if nothing has been set.

The module is sourced by the shell. The wakeup-module is executed as user root.


The Main part of the wakeup-module:

A wakeup-module should do nothing in its main part.


Return values of functions:
	=  0 	- success
	<> 0	- failure




Functions to be defined:

wakeup_check:
	Should return 0 when setting wakeup is possible
	else it should return a non-zero return value
	and set an error-message.
	i.e. check for existence of used programms ...

set_wakeup:
	Do the real work. It gets the time to wakeup as
	first parameter in Unix-Format (Seconds since 1970-01-01 UTC)
	and should do whatever necessary
	to let the system be up at that time.


Usable functions:

void error_mesg(string message)
	Sets an error message



Example:

wakeup_check() {
	if [ ! -x needed_program ]; then
		error_mesg "no acpi-driver installed"
		return 1
	fi

	return 0
}

wakeup_set() {
	pass_wakeup_time_to_hardware "${1}"
}

Usable functions:

void error_mesg(string message)
	Sets an error message

void set_reboot_needed(void)
	Call in wakeup_set when you need to reboot
	for setting the time.



=====================
= pre-shutdown-hooks:
=====================

It is possible to insert code in the shutdown-procedure.
Most time this will be used to check for conditions which should
prevent a shutdown.

Usable functions:

bool is_auto_shutdown(void)
	Returns true if this shutdown is triggered by minuserinactivity or after a timer-recording

bool is_user_shutdown(void)
	Returns true if this shutdown is triggered by the user pressing on power.

void shutdown_abort(string message)
	Forces shutdown to abort and sets a message why it must be aborted.

void shutdown_abort_can_force(string message)
	Same function as shutdown_abort. Shutdown is aborted.
	But if user presses the power-button again inside a minute (configurable) then shutdown
	is forced meaning this condition will not stop shutdown then.

void shutdown_abort_exit(string message)
	For special cases!
	Immediately exit shutdown-process with exitcode 1.

bool is_forced_shutdown(void)
	Returns true if this shutdown has been forced in the sense of shutdown_abort_can_force.


void disable_auto_retry(void)
	Disables the auto-retry of a failed shutdown. Most times only for internal usage.

void set_retry_time(int time_minutes)
	Tells shutdown-script to retry not before time_minutes minutes.



===============================
= storage-format for tmp-files:
===============================

Tmp-files for shutdown are stored under /var/vdr/shutdown-data
All stored times are unix-timestamps

$datadir/shutdown-need-reboot:
  stores time a wakeup-method requested to reboot
  Is then compared to the uptime of the system.

$datadir/shutdown-time-written
  stores the time a wakeup-time was written to the
  hardware.

$datadir/last-shutdown-abort
  stores the time whenever a shutdown is aborted because
  of some pre-shutdown hooks and the tests can be forced