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/lib/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