C't-VDR - Hooks

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
(command-hooks: Formatiert)
(Struktur etwas verändert)
Zeile 1: Zeile 1:
=Hooks=
 
 
Hooks sind kleine Scripte, die das VDR Hauptprogramm bei einer bestimmten Aktion aufruft.
 
Hooks sind kleine Scripte, die das VDR Hauptprogramm bei einer bestimmten Aktion aufruft.
 
Die einzelnen Hooks werden ähnlich wie die Init-Prozesse in verschiedenen Verzeichnissen
 
Die einzelnen Hooks werden ähnlich wie die Init-Prozesse in verschiedenen Verzeichnissen
Zeile 5: Zeile 4:
  
 
Es gibt drei Arten von Hooks:
 
Es gibt drei Arten von Hooks:
* command-hooks   
+
* command-hooks   
* recording-hooks   
+
* recording-hooks   
* shutdown-hooks
+
* shutdown-hooks
  
==command-hooks==
+
=command-hooks=
 +
==Beispiele==
  
 +
=recording-hooks=
 +
Recording Hooks befinden sich meistens in dem Verzeichnis
 +
/usr/share/vdrdevel/recording-hooks
 +
oder
 +
/usr/share/vdr/recording-hooks
  
===Selbsterstellte VDR Shutdown Hook===
+
Beschreibung:
  
Here you can place any commands, you want to be executed when VDR wants to shutdown.
+
This is a custom Recording Action Hook. It gets called by vdrdevel
 +
before a recording starts, after a recording ended and after a
 +
recording has been edited. It is maintained as a config file in the vdrdevel
 +
package. All other recording hooks get executed before this one!
  
* To abort the shutdown, exit with an errorlevel <> 0.
+
If you want to create your own recording hook that may get executed
 +
before any other hook, create it in /usr/share/vdrdevel/recording-hooks or
 +
link to this location. All hooks are called in their alphabetical
 +
order and should follow this naming scheme:
  
* If you want a message to be displayed on the OSD when aborting a shutdown, then write to stdout:
+
R<XX>.<identifier>
  
ABORT_MESSAGE=<message to display>
+
Where <XX> is a two digit number, that mainly specifies the execution order
 +
and <identifier> is a unique descriptor.
  
* If you want to defer the shutdown, write to stdout:
+
Two parameters are passed:
  
TRY_AGAIN=<minutes to wait before next shutdown request>
+
Parameter 1 can have the values "before", "after" and "edited", depending
 +
on whether the recording hook is called before the recording starts,
 +
after the recording ends or after the recording has been edited.
  
* To overwrite the command that will be executed to shutdown the machine after all shutdown hooks have been processed, write to stdout:
+
Parameter 2 is the directory of the recording. Be aware, that this directory
 +
doesn't exist before the recording starts.
  
SHUTDOWNCMD=<new shutdown command>
 
  
i.e.:
+
  case $1 in
 
+
before)
  echo "ABORT_MESSAGE=\"I do not want to shutdown now!\"" ; exit 1
+
# do here what ever you would like to do right BEFORE
 
+
# the recording $2 STARTS
==recording-hooks==
+
;;
Recording Hooks befinden sich meistens in dem Verzeichnis
+
after)
/usr/share/vdrdevel/recording-hooks
+
# do here what ever you would like to do right AFTER
oder
+
# the recording $2 ENDED
/usr/share/vdr/recording-hooks
+
;;
 
+
edited)
Vorlage (aus dem Verzeichnis kopiert)
+
# do here what ever you would like to do right AFTER
<pre>
+
# the recording $2 has been EDITED
# Custom VDR Recording Action Hook
+
;;
# ----------------------------------
+
esac
#
+
==Beispiele==
# This is a custom Recording Action Hook. It gets called by vdrdevel
+
# before a recording starts, after a recording ended and after a
+
# recording has been edited. It is maintained as a config file in the vdrdevel
+
# package. All other recording hooks get executed before this one!
+
#
+
# If you want to create your own recording hook that may get executed
+
# before any other hook, create it in /usr/share/vdrdevel/recording-hooks or
+
# link to this location. All hooks are called in their alphabetical
+
# order and should follow this naming scheme:
+
#
+
# R<XX>.<identifier>
+
#
+
# Where <XX> is a two digit number, that mainly specifies the execution order
+
# and <identifier> is a unique descriptor.
+
#
+
# Two parameters are passed:
+
#
+
# Parameter 1 can have the values "before", "after" and "edited", depending
+
# on whether the recording hook is called before the recording starts,
+
# after the recording ends or after the recording has been edited.
+
#
+
# Parameter 2 is the directory of the recording. Be aware, that this directory
+
# doesn't exist before the recording starts.
+
#
+
 
+
case $1 in
+
before)
+
# do here what ever you would like to do right BEFORE
+
# the recording $2 STARTS
+
;;
+
after)
+
# do here what ever you would like to do right AFTER
+
# the recording $2 ENDED
+
;;
+
edited)
+
# do here what ever you would like to do right AFTER
+
# the recording $2 has been EDITED
+
;;
+
esac
+
 
+
</pre>
+
 
+
==shutdown-hooks==
+
 
+
==Beispiel-Hooks==
+
 
===Aufnahmen Schreibrechte zuweisen===
 
===Aufnahmen Schreibrechte zuweisen===
 
Dieses kleine Script gibt dem kompletten Aufnahmeverzeichnis Schreibrechte  
 
Dieses kleine Script gibt dem kompletten Aufnahmeverzeichnis Schreibrechte  
Zeile 106: Zeile 75:
  
 
Anmerkung: Entgegen einigen Behauptungen funktioniert es NICHT, den VDR Prozess mit einer bestimmten umask Einstellung zu starten. Der VDR legt beim Öffnen der Dateien explizit die Zugriffsrechte fest und überschreibt somit die umask Einstellung. Dieses Script stellt eine Alternative zum Verändern des Quelltextes dar.
 
Anmerkung: Entgegen einigen Behauptungen funktioniert es NICHT, den VDR Prozess mit einer bestimmten umask Einstellung zu starten. Der VDR legt beim Öffnen der Dateien explizit die Zugriffsrechte fest und überschreibt somit die umask Einstellung. Dieses Script stellt eine Alternative zum Verändern des Quelltextes dar.
 +
 +
 +
=shutdown-hooks=
 +
 +
 +
Here you can place any commands, you want to be executed when VDR wants to shutdown.
 +
 +
* To abort the shutdown, exit with an errorlevel <> 0.
 +
 +
* If you want a message to be displayed on the OSD when aborting a shutdown, then write to stdout:
 +
 +
ABORT_MESSAGE=<message to display>
 +
 +
* If you want to defer the shutdown, write to stdout:
 +
 +
TRY_AGAIN=<minutes to wait before next shutdown request>
 +
 +
* To overwrite the command that will be executed to shutdown the machine after all shutdown hooks have been processed, write to stdout:
 +
 +
SHUTDOWNCMD=<new shutdown command>
 +
 +
i.e.:
 +
 +
echo "ABORT_MESSAGE=\"I do not want to shutdown now!\"" ; exit 1
 +
==Beispiele==
 +
 +
===IMAP Mail===
 +
Dieses kleine Script hält den Shutdown Prozess an, falls noch Imap Sessions geöffnet sind.
 +
Alternativ können auch andere Prozesse überprüft werden.
 +
 +
{{Box Datei|/usr/share/vdrdevel/recording-hooks/S90.imapmail|
 +
#
 +
# Imap checking script
 +
 +
ps -ae | grep -q imap
 +
 +
if [ $? -eq 0 ] ; then
 +
  echo "waitung 5 minutes"
 +
  TRY_AGAIN=5
 +
fi
 +
 +
}}

Version vom 22. Oktober 2005, 00:17 Uhr

Hooks sind kleine Scripte, die das VDR Hauptprogramm bei einer bestimmten Aktion aufruft. Die einzelnen Hooks werden ähnlich wie die Init-Prozesse in verschiedenen Verzeichnissen gespeichert und alphabetisch aufgerufen. Die Namen beginnen allerdings immer mit einer zweistelligen Zahl, sodass die Reihenfolge immer festliegt.

Es gibt drei Arten von Hooks:

  • command-hooks
  • recording-hooks
  • shutdown-hooks

Inhaltsverzeichnis

command-hooks

Beispiele

recording-hooks

Recording Hooks befinden sich meistens in dem Verzeichnis

/usr/share/vdrdevel/recording-hooks 

oder

/usr/share/vdr/recording-hooks

Beschreibung:

This is a custom Recording Action Hook. It gets called by vdrdevel before a recording starts, after a recording ended and after a recording has been edited. It is maintained as a config file in the vdrdevel package. All other recording hooks get executed before this one!

If you want to create your own recording hook that may get executed before any other hook, create it in /usr/share/vdrdevel/recording-hooks or link to this location. All hooks are called in their alphabetical order and should follow this naming scheme:

R<XX>.<identifier>

Where <XX> is a two digit number, that mainly specifies the execution order and <identifier> is a unique descriptor.

Two parameters are passed:

Parameter 1 can have the values "before", "after" and "edited", depending on whether the recording hook is called before the recording starts, after the recording ends or after the recording has been edited.

Parameter 2 is the directory of the recording. Be aware, that this directory doesn't exist before the recording starts.


case $1 in
	before)
		# do here what ever you would like to do right BEFORE
		# the recording $2 STARTS
		;;
	after)
		# do here what ever you would like to do right AFTER
		# the recording $2 ENDED
		;;
	edited)
		# do here what ever you would like to do right AFTER
		# the recording $2 has been EDITED
		;;
esac

Beispiele

Aufnahmen Schreibrechte zuweisen

Dieses kleine Script gibt dem kompletten Aufnahmeverzeichnis Schreibrechte

Datei
/usr/share/vdrdevel/recording-hooks/R90.makepublic
#
# Vergibt Schreibrechte der Gruppe
# ----------------------------------
 case $1 in
    after)
        chmod -R g+w $2/*
        chmod g+w $2
        ;;
esac 


Anmerkung: Entgegen einigen Behauptungen funktioniert es NICHT, den VDR Prozess mit einer bestimmten umask Einstellung zu starten. Der VDR legt beim Öffnen der Dateien explizit die Zugriffsrechte fest und überschreibt somit die umask Einstellung. Dieses Script stellt eine Alternative zum Verändern des Quelltextes dar.


shutdown-hooks

Here you can place any commands, you want to be executed when VDR wants to shutdown.

  • To abort the shutdown, exit with an errorlevel <> 0.
  • If you want a message to be displayed on the OSD when aborting a shutdown, then write to stdout:
ABORT_MESSAGE=<message to display>
  • If you want to defer the shutdown, write to stdout:
TRY_AGAIN=<minutes to wait before next shutdown request>
  • To overwrite the command that will be executed to shutdown the machine after all shutdown hooks have been processed, write to stdout:
SHUTDOWNCMD=<new shutdown command>

i.e.:

echo "ABORT_MESSAGE=\"I do not want to shutdown now!\"" ; exit 1

Beispiele

IMAP Mail

Dieses kleine Script hält den Shutdown Prozess an, falls noch Imap Sessions geöffnet sind. Alternativ können auch andere Prozesse überprüft werden.

Datei
/usr/share/vdrdevel/recording-hooks/S90.imapmail
#
# Imap checking script

ps -ae