C't-VDR - Hooks

Aus VDR Wiki
Wechseln zu: Navigation, Suche

Inhaltsverzeichnis

Hooks

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

command-hooks

Selbsterstellte VDR Shutdown Hook

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

recording-hooks

Recording Hooks befinden sich meistens in dem Verzeichnis

/usr/share/vdrdevel/recording-hooks 

oder

/usr/share/vdr/recording-hooks

Vorlage (aus dem Verzeichnis kopiert)

# Custom VDR Recording Action Hook
# ----------------------------------
#
# 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

shutdown-hooks

Beispiel-Hooks

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.