aboutsummaryrefslogtreecommitdiff
blob: 36ddc47a80fdf4f9a3d90d3d30b34c00ecaad387 (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
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 rtc and nvram is tried 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 just set the time provided in the variable VDR_WAKEUP_TIME its main part.

	It gets the time in Unix-Format (Seconds since 1970-01-01 UTC)
	and should do whatever necessary
	to let the system be up at that time.


Return values:
	=  0 	- success
	!= 0	- failure

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.


Example:

if [ ! -x needed_program ]; then
	error_mesg "no wakeup-driver installed"
	return 1
fi

pass_wakeup_time_to_hardware "${1}"



=====================
= 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