summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUdo Richter <udo_richter@gmx.de>2006-10-08 00:00:00 +0200
committerManuel Reimer <manuel.reimer@gmx.de>2013-10-01 17:11:15 +0200
commit302bca7e5c430fc4a3ebf619b5e15a0d8690662a (patch)
tree04cbda642c27763817b005856a472afeb81fedb1
downloadrunvdr-extreme-302bca7e5c430fc4a3ebf619b5e15a0d8690662a.tar.gz
runvdr-extreme-302bca7e5c430fc4a3ebf619b5e15a0d8690662a.tar.bz2
Version 0.1.0v0.1.0
* Initial revision.
-rw-r--r--COPYING340
-rw-r--r--HISTORY7
-rw-r--r--README118
-rw-r--r--README.de117
-rwxr-xr-xrunvdr705
-rw-r--r--runvdr.conf.example165
6 files changed, 1452 insertions, 0 deletions
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..5b6e7c6
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/HISTORY b/HISTORY
new file mode 100644
index 0000000..ce15e71
--- /dev/null
+++ b/HISTORY
@@ -0,0 +1,7 @@
+runvdr extreme Revision History
+-------------------------------
+
+2006-10-08: Version 0.1
+
+- Initial revision.
+
diff --git a/README b/README
new file mode 100644
index 0000000..04f27c0
--- /dev/null
+++ b/README
@@ -0,0 +1,118 @@
+
+ runvdr extreme
+
+
+Written by: Udo Richter <udo_richter(a)gmx.de>
+Project's homepage: http://www.richter-udo.de/vdr/scripts.en.html#runvdr
+See the file COPYING for license information.
+
+
+
+About
+--------------------------------------------------------------------------
+runvdr extreme is a runvdr script, just like the runvdr script included in
+the VDR distribution. Its just roughly 17 times bigger.
+
+Some of the features of runvdr extreme:
+
+- Loads default configuration from runvdr.conf
+- All configuration accessible and overrideable from command line
+- All VDR options handled
+- Handles runvdr.pid file, acts on signals
+- Restarts VDR in case of errors
+- Commands to restart VDR and reload DVB
+- Configuration file re-read on VDR restart
+- Avoids endless loops if VDR crashes instantly
+- Resets terminal to defaults after VDR terminated
+- Add wrapper commands to VDR for debugging
+- Waiting for the VDR process to be killed completey,
+ hard killing after timeout
+- Command line help
+- Can switch console terminal
+- Can set locale for VDR daemon
+- Optionally supports pluginsetup-plugin
+
+
+
+Quick-start
+--------------------------------------------------------------------------
+- Copy runvdr to /usr/local/bin/ or whereever you like
+- Copy runvdr.conf.example to /etc/runvdr.conf
+- Edit /etc/runvdr.conf to match your needs
+
+The runvdr.conf is pretty much self-explaining. All options are also available
+on command line, just take a look at runvdr --help.
+
+
+
+Dependencies
+--------------------------------------------------------------------------
+Unix commands, that runvdr uses:
+
+Command Debian packet
+ pgrep procps
+ ps procps
+ kill procps
+ sleep coreutils
+ date coreutils
+ chvt console-tools
+ getopt util-linux
+ setterm util-linux
+
+
+
+Examples
+--------------------------------------------------------------------------
+Assuming you've set up your defaults in /etc/runvdr.conf, here are some
+cool things you can do now:
+
+
+Start VDR in background (for example with TERMINAL=/dev/tty8 in conf file):
+
+ runvdr &
+
+Stop VDR and the runvdr script:
+
+ runvdr --terminate
+
+Dito, but wait until VDR is killed:
+
+ runvdr --terminate --wait
+
+Restart the already running VDR process because it is hanging, or because
+the runvdr.conf has changed:
+
+ runvdr --restart
+
+Dito, but also reload the DVB drivers:
+
+ runvdr --dvb-restart
+
+Use the new fresh compiled VDR for the first time:
+
+ runvdr --vdr=/usr/src/vdr-1.4.3/vdr --lib=/usr/src/vdr-1.4.3/PLUGINS/lib
+
+For debugging, start VDR with no terminal redirection:
+
+ runvdr --terminal="" --switchterminal=""
+
+Load all plugins and also the hello plugin:
+
+ runvdr -P hello
+
+Load only the hello plugin:
+
+ runvdr -P- -P hello
+
+Do a dry-run of runvdr:
+
+ runvdr --wrapper=echo
+
+Do a debugging session:
+
+ runvdr --wrapper="gdb --args"
+
+Start with a completely different setup:
+
+ runvdr --runvdr-conf="/etc/runvdr-debugging.conf"
+
diff --git a/README.de b/README.de
new file mode 100644
index 0000000..65803d8
--- /dev/null
+++ b/README.de
@@ -0,0 +1,117 @@
+
+ runvdr extreme
+
+Geschrieben von: Udo Richter <udo_richter(a)gmx.de>
+Projekt Homepage: http://www.richter-udo.de/vdr/scripts.html#runvdr
+Siehe Datei COPYING für Lizenz-Informationen
+
+
+
+Über
+--------------------------------------------------------------------------
+runvdr extreme ist ein runvdr-Skript, genau wie das runvdr-Skript aus
+der VDR-Distribution. Es ist nur rund 17 mal größer.
+
+Einige der Features von runvdr extreme:
+
+- Lädt die Grundkonfiguration aus runvdr.conf
+- Die gesamte Konfiguration kann per Kommandozeile gesetzt werden
+- Alle VDR-Optionen werden unterstützt
+- Verwaltet runvdr.pid Datei, reagiert auf Signale
+- Startet VDR im Falle von Fehlern neu
+- Kommandos, um VDR neu zu starten und DVB-Treiber neu zu laden
+- Beim VDR-Neustart wird die Konfiguration erneut gelesen
+- Vermeidet endlose Schleifen, wenn VDR sofort stirbt
+- Setzt Terminal zurück nachdem VDR beendet wurde
+- Starten von Wrapper-Programmen zum Debuggen
+- Wartet bis der VDR-Prozess beendet wurde,
+ hartes Beenden nach Timeout
+- Kommandozeilenhilfe
+- Kann Konsole umschalten
+- Kann Landessprache für VDR setzen
+- Unterstützt Pluginsetup-Plugin optional
+
+
+
+Schnellstart
+--------------------------------------------------------------------------
+- Kopiere runvdr nach /usr/local/bin/ oder wo-auch-immer-du-magst
+- Kopiere runvdr.conf.example nach /etc/runvdr.conf
+- Bearbeite /etc/runvdr.conf nach deinem Bedarf
+
+Die runvdr.conf ist größtenteils selbsterklärend. Alle Optionen sind auch
+per Kommandozeile verfügbar, siehe runvdr --help.
+
+
+
+Voraussetzungen
+--------------------------------------------------------------------------
+Unix-Kommandos, die runvdr benutzt:
+
+Kommando Debian-Paket
+ pgrep procps
+ ps procps
+ kill procps
+ sleep coreutils
+ date coreutils
+ chvt console-tools
+ getopt util-linux
+ setterm util-linux
+
+
+
+Beispiele
+--------------------------------------------------------------------------
+Wenn die Standardeinstellungen in /etc/runvdr.conf vorgenommen sind, hier
+ein paar coole Dinge, die man tun kann:
+
+
+Starte VDR im Hintergrund (zum Beispiel mit TERMINAL=/dev/tty8 in conf-Datei):
+
+ runvdr &
+
+Stoppe VDR und das runvdr-Skript:
+
+ runvdr --terminate
+
+Dito, aber warte bis VDR beendet ist:
+
+ runvdr --terminate --wait
+
+Starte den bereits laufenden VDR-Prozess neu, weil er hängt, oder
+weil die runvdr.conf geändert wurde:
+
+ runvdr --restart
+
+Dito, aber lade auch die DVB-Treiber neu:
+
+ runvdr --dvb-restart
+
+Benutze den frich neu übersetzten VDR zum ersten mal:
+
+ runvdr --vdr=/usr/src/vdr-1.4.3/vdr --lib=/usr/src/vdr-1.4.3/PLUGINS/lib
+
+Zum Debuggen, starte VDR ohne Terminalumlenkung:
+
+ runvdr --terminal="" --switchterminal=""
+
+Lade alle Plugins, und zusätzlich das hello-Plugin:
+
+ runvdr -P hello
+
+Lade nur das hello-Plugin:
+
+ runvdr -P- -P hello
+
+Starte einen Testlauf von runvdr, um zu sehen was passiert:
+
+ runvdr --wrapper=echo
+
+Starte eine Debugging-Session:
+
+ runvdr --wrapper="gdb --args"
+
+Starte mit einer komplett abweichenden Konfiguration:
+
+ runvdr --runvdr-conf="/etc/runvdr-debugging.conf"
+
diff --git a/runvdr b/runvdr
new file mode 100755
index 0000000..b186a38
--- /dev/null
+++ b/runvdr
@@ -0,0 +1,705 @@
+#!/bin/bash
+#
+# runvdr extreme
+#
+# configurable vdr launcher script
+#
+# by Udo Richter <udo_richter(a)gmx.de>
+# http://www.richter-udo.de/vdr/scripts.html#runvdr
+#
+
+RUNVDRCONF=/etc/runvdr.conf
+
+
+# Some unix commands being used:
+
+PGREP="pgrep"
+PS="ps"
+GETOPT="getopt"
+KILL="kill"
+SLEEP="sleep"
+CHVT="chvt"
+DATE="date"
+SETTERM="setterm"
+
+# Options summary and conf file entries of runvdr:
+#
+# -C # --runvdr-conf=# RUNVDRCONF location of runvdr config file
+# -- ADDPARAM Additional parameters to pass to VDR
+# --pluginsetup-conf=# PLUGINSETUPCONF location of plugin-setup-runvdr.conf
+# --vdr=# VDRPRG location and name of the vdr binary
+# --switchterminal=# SWITCHTERMINAL console terminal to switch to
+# --runvdr-pid=# RUNVDRPID location of runvdr.pid file
+# --dvb-load=# DVBLOAD command to load DVB drivers
+# --dvb-unload=# DVBUNLOAD command to unload DVB drivers
+# --wrapper=# WRAPPER wrapper command for calling vdr
+# --terminate[=#] TERMINATE Terminate runvdr by pid
+# --wait[=#] WAIT Wait # seconds for --terminate to finish
+# --restart[=#] RESTART Send restart signal by pid
+# --dvb-restart[=#] DVBRESTART Send dvb-restart signal by pid
+# --term-timeout=# TERMTIMEOUT Timeout for VDR to react on SIGTERM
+# --kill-timeout=# KILLTIMEOUT Timeout for VDR to react on SIGKILL
+# --language=# LANGUAGE Locale to set for VDR
+# -V --version VERSION print version information and exit
+# -h --help HELP print this help and exit
+#
+# Supported options of VDR
+#
+# -a # --audio # AUDIO send Dolby Digital audio to stdin of command #
+# -c # --config # CONFIGDIR read config files from DIR
+# -d --daemon DAEMON run in daemon mode
+# -D # --device # DVBDEVICE use only the given DVB device (NUM = 0, 1, 2...)
+# -E # --epgfile # EPGFILE write the EPG data into the given FILE. - to disable.
+# -g # --grab # GRAB write images from the SVDRP command GRAB into the given DIR;
+# -L # --lib # LIBDIR search for plugins in DIR (default is %s)
+# --lirc #? LIRC use a LIRC remote control device, attached to PATH
+# -l # --log # LOGLEVEL set log level (default: 3)
+# -m --mute MUTE mute audio of the primary DVB device at startup
+# --no-kbd NOKBD don't use the keyboard as an input device
+# -P # --plugin # PLUGINS load a plugin defined by the given options
+# -p # --port # SVDRPPORT use PORT for SVDRP
+# --rcu #? RCU use a remote control device, attached to PATH
+# -r # --record # RECORDCMD call CMD before and after a recording
+# -s # --shutdown # SHUTDOWN call CMD to shutdown the computer
+# -t # --terminal # TERMINAL controlling tty
+# -u # --user # USER run as user USER; only applicable if started as root
+# -v --vfat VFAT encode special characters in recording names
+# -v # --video # VIDEODIR use DIR as video directory
+# -w # --watchdog # WATCHDOG activate the watchdog timer with a timeout of SEC
+
+
+which $PGREP >- || { echo missing $PGREP... >2 ; exit 1 ; }
+which $PS >- || { echo missing $PS... >2 ; exit 1 ; }
+which $GETOPT >- || { echo missing $GETOPT... >2 ; exit 1 ; }
+which $KILL >- || { echo missing $KILL... >2 ; exit 1 ; }
+which $SLEEP >- || { echo missing $SLEEP... >2 ; exit 1 ; }
+which $CHVT >- || { echo missing $CHVT... >2 ; exit 1 ; }
+which $DATE >- || { echo missing $DATE... >2 ; exit 1 ; }
+which $SETTERM >- || { echo missing $SETTERM... >2 ; exit 1 ; }
+
+
+
+function ParseCommandLine_Step1() {
+ # Parse command line, step 1
+ # Stores pre-processed options in $OPTIONS
+ # evaluates -C and --runvdr-conf only
+
+ SHORTOPT="a:c:C:dD:E:g:hl:L:mp:P:r:s:t:u:v:Vw:"
+ LONGOPT="runvdr-conf:,pluginsetup-conf:,vdr:,switchterminal:,\
+ runvdr-pid:,dvb-load:,dvb-unload:,language:,wrapper:,\
+ term-timeout:,kill-timeout:,terminate::,restart::,dvb-restart::,\
+ wait::,audio:,config:,daemon,device:,epgfile:,grab:,help,lib:,lirc::,\
+ log:,mute,no-kbd,plugin:,port:,rcu::,record:,shutdown:,\
+ terminal:,user:,version,vfat,video:,watchdog:"
+
+
+ # prepare all optios for later processing
+ OPTIONS=`$GETOPT -o "$SHORTOPT" --long "$LONGOPT" -n "$0" -- "$@"` || exit 1
+
+ # evaluate only -C and --runvdr-conf
+ EARLYOPTIONS=`$GETOPT -q -o "C:" --long "runvdr-conf:" -n "$0" -- "$@"`
+
+ eval set -- "$EARLYOPTIONS"
+
+ while true ; do case "$1" in
+ -C|--runvdr-conf)
+ RUNVDRCONF="$2"
+ shift 2
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ echo "Internal error!" >2
+ exit 1
+ ;;
+ esac ; done
+}
+
+function Clean() {
+ # Clean all config variables
+ ADDPARAM=
+ PLUGINSETUPCONF=
+ VDRPRG=
+ SWITCHTERMINAL=
+ RUNVDRPID=
+ DVBLOAD=
+ DVBUNLOAD=
+ LANGUAGE=
+ WRAPPER=
+ TERMTIMEOUT=
+ KILLTIMEOUT=
+ TERMINATE=
+ RESTART=
+ DVBRESTART=
+ WAIT=0
+ HELP=
+ VERSION=
+
+ AUDIO=
+ CONFIGDIR=
+ DAEMON=
+ DVBDEVICE=()
+ EPGFILE=
+ GRAB=
+ LIBDIR=
+ LIRC=
+ LOGLEVEL=
+ MUTE=
+ NOKBD=
+ PLUGINS=()
+ SVDRPPORT=
+ RECORDCMD=
+ RCU=
+ SHUTDOWN=
+ TERMINAL=
+ VDRUSER=
+ VFAT=
+ VIDEODIR=
+ WATCHDOG=
+}
+
+
+# Helper functions
+function AddPluginString() {
+ # add $1 as plugin
+ if [ "$1" == "-" ] ; then
+ PLUGINS=()
+ else
+ PLUGINS[${#PLUGINS[*]}]="$*"
+ fi
+}
+function AddPlugin() {
+ # add $* as plugin, do shell quoting
+
+ local plugin=""
+ while [ $# -gt 0 ] ; do
+ # regexp magic
+ # quote '\' to '\\'
+ local par="$1"
+ par="${par//'\'/\\\\}"
+ # work around bash bug: double quoted '\'
+ par="${par//'\\'/\\\\}"
+ # quote '"' to '\"'
+ par="${par//\"/\\\"}"
+ # check if this splits into words
+ local -a arr=($par)
+ # if yes, wrap in quotes
+ [ ${#arr[*]} -ne 1 ] && par="\"$par\""
+ # add to plugin string
+ if [ -n "$plugin" ] ; then plugin="$plugin $par" ; else plugin="$par" ; fi
+ # next, please
+ shift
+ done
+ AddPluginString "$plugin"
+}
+function AddDevice() {
+ if [ "$1" == "-" ] ; then
+ DVBDEVICE=()
+ else
+ DVBDEVICE[${#DVBDEVICE[*]}]="$*";
+ fi
+}
+
+
+function LoadConfFile() {
+
+ # Load configuration file
+
+ if [ -r $RUNVDRCONF ] ; then
+ . $RUNVDRCONF || exit 1
+ else
+ echo "runvdr: $RUNVDRCONF not found." >&2
+ fi
+
+ # Transform some defaults, so empty parameters can have a
+ # non-default meaning
+ [ -z "$LIRC" ] && LIRC=0
+ [ -z "$RCU" ] && RCU=0
+ [ -z "$TERMINATE" ] && TERMINATE=0
+ [ -z "$RESTART" ] && RESTART=0
+ [ -z "$DVBRESTART" ] && DVBRESTART=0
+
+ return 0
+}
+
+
+function ParseCommandLine_Step2() {
+ # Parse command line, step 2
+ # Process all options in $OPTIONS, override
+ # all options that are set by now
+
+ eval set -- "$OPTIONS"
+
+ while true ; do case "$1" in
+ -C|--runvdr-conf) shift 2;;
+ --pluginsetup-conf) PLUGINSETUPCONF="$2"; shift 2;;
+ --vdr) VDRPRG="$2"; shift 2;;
+ --switchterminal) SWITCHTERMINAL="$2"; shift 2;;
+ --runvdr-pid) RUNVDRPID="$2"; shift 2;;
+ --dvb-load) DVBLOAD="$2"; shift 2;;
+ --dvb-unload) DVBUNLOAD="$2"; shift 2;;
+ --language) LANGUAGE="$2"; shift 2;;
+ --wrapper) WRAPPER="$2"; shift 2;;
+ --term-timeout) TERMTIMEOUT="$2"; shift 2;;
+ --kill-timeout) KILLTIMEOUT="$2"; shift 2;;
+ --terminate) TERMINATE="$2"; shift 2;;
+ --wait) WAIT="$2"; shift 2;;
+ --restart) RESTART="$2"; shift 2;;
+ --dvb-restart) DVBRESTART="$2"; shift 2;;
+ -h|--help) HELP=1; shift ;;
+ -V|--version) VERSION=1; shift ;;
+
+
+ -a|--audio) AUDIO="$2"; shift 2;;
+ -c|--config) CONFIGDIR="$2"; shift 2;;
+ -d|--daemon) DAEMON=1; shift ;;
+ -D|--device) AddDevice "$2"; shift 2;;
+ -E|--epgfile) EPGFILE="$2"; shift 2;;
+ -g|--grab) GRAB="1"; shift ;;
+ -l|--log) LOGLEVEL="$2"; shift 2;;
+ -L|--lib) LIBDIR="$2"; shift 2;;
+ --lirc) LIRC="$2"; shift 2;;
+ -m|--mute) MUTE=1; shift ;;
+ --no-kbd) NOKBD=1; shift ;;
+ -p|--port) SVDRPPORT="$2"; shift 2;;
+ -P|--plugin) AddPluginString "$2"; shift 2;;
+ --rcu) RCU="$2"; shift 2;;
+ -r|--record) RECORDCMD="$2"; shift 2;;
+ -s|--shutdown) SHUTDOWN="$2"; shift 2;;
+ -t|--terminal) TERMINAL="$2"; shift 2;;
+ -u|--user) USER="$2"; shift 2;;
+ -v|--video) VIDEODIR="$2"; shift 2;;
+ --vfat) VFAT=1; shift ;;
+ -w|--watchdog) WATCHDOG="$2"; shift 2;;
+
+
+ --)
+ shift
+ break
+ ;;
+ *)
+ echo "Internal error!" >2
+ exit 1
+ ;;
+ esac ; done
+
+ # Add all remaining options directly to additional params
+
+ if [ -n "$1" ] ; then
+ [ -n "$ADDPARAM" ] && ADDPARAM="$ADDPARAM "
+ ADDPARAM="$ADDPARAM$@"
+ fi
+
+ return 0
+}
+
+
+
+function OnlineHelp() {
+ cat <<END-OF-HELP
+Usage: $0 [OPTIONS]
+
+runvdr Options:
+-C #, --runvdr-conf=# location of runvdr config file
+--pluginsetup-conf=# location of plugin-setup-runvdr.conf
+--vdr=# location and name of the vdr binary
+--switchterminal=# console terminal number to switch to
+--runvdr-pid=# location of runvdr.pid file
+--dvb-load=# command to load DVB drivers
+--dvb-unload=# command to unload DVB drivers
+--wrapper=# wrapper command for calling vdr
+--language=# Locale to set for VDR
+--terminate[=#] Terminate runvdr by pid
+--wait[=#] Wait # seconds for --terminate to finish
+--restart[=#] Send restart signal by pid
+--dvb-restart[=#] Send dvb-restart signal by pid
+--term-timeout=# Timeout for VDR to react on SIGTERM
+--kill-timeout=# Timeout for VDR to react on SIGKILL
+
+-V, --version print version information and exit
+-h, --help print this help and exit
+
+Parsed VDR options:
+-a # --audio=# send Dolby Digital audio to stdin of command CMD
+-c # --config=# read config files from DIR
+-d --daemon run in daemon mode
+-D # --device=# use only the given DVB device (NUM = 0, 1, 2...)
+ Use '-' to override devices from config file
+-E # --epgfile=# write the EPG data into the given FILE. - to disable.
+-g # --grab=# write images from the SVDRP command GRAB into the given DIR
+-L # --lib=# search for plugins in DIR
+ --lirc[=#] use a LIRC remote control device, attached to PATH
+-l # --log=# set log level
+-m --mute mute audio of the primary DVB device at startup
+ --no-kbd don't use the keyboard as an input device
+-P # --plugin=# load a plugin defined by the given options
+ Use '-' to ignore plugins from config file
+-p # --port=# use PORT for SVDRP
+ --rcu[=#] use a remote control device, attached to PATH
+-r # --record=# call CMD before and after a recording
+-s # --shutdown=# call CMD to shutdown the computer
+-t # --terminal=# controlling tty
+-u # --user=# run as user USER; only applicable if started as root
+ --vfat encode special characters in recording names
+-v # --video=# use DIR as video directory
+-w # --watchdog=# activate the watchdog timer with a timeout of SEC
+
+All runvdr parameters after '--' will be passed to VDR without modification
+END-OF-HELP
+}
+
+function BuildCommand() {
+ # Based on all options, build command line in $VDRCMD
+
+ # complete command with path
+ VDRPRG=`which "$VDRPRG"`
+ if [ -z "$VDRPRG" ] ; then
+ echo "VDR command binary not found."
+ exit 1
+ fi
+
+ # Build up command line:
+ VDRCMD="$VDRPRG"
+ [ -n "$ADDPARAM" ] && VDRCMD="$VDRCMD $ADDPARAM"
+ [ -n "$WRAPPER" ] && VDRCMD="$WRAPPER $VDRCMD"
+
+ [ -n "$AUDIO" ] && VDRCMD="$VDRCMD -a \"$AUDIO\""
+ [ -n "$CONFIGDIR" ] && VDRCMD="$VDRCMD -c \"$CONFIGDIR\""
+ [ -n "$DAEMON" ] && VDRCMD="$VDRCMD -d"
+
+ for ((i=0;i<${#DVBDEVICE[*]};i++)) ; do
+ [ -n "${DVBDEVICE[i]}" ] && VDRCMD="$VDRCMD -D ${DVBDEVICE[i]}"
+ done
+
+ [ -n "$EPGFILE" ] && VDRCMD="$VDRCMD -E \"$EPGFILE\""
+ [ -n "$GRAB" ] && VDRCMD="$VDRCMD -g"
+ [ -n "$LOGLEVEL" ] && VDRCMD="$VDRCMD -l $LOGLEVEL"
+ [ -n "$LIBDIR" ] && VDRCMD="$VDRCMD -L $LIBDIR"
+ case "$LIRC" in
+ 1|"") VDRCMD="$VDRCMD --lirc";;
+ 0) ;;
+ *) VDRCMD="$VDRCMD --lirc=\"$LIRC\"";;
+ esac
+ [ -n "$MUTE" ] && VDRCMD="$VDRCMD -m"
+ [ -n "$NOKBD" ] && VDRCMD="$VDRCMD --no-kbd"
+ [ -n "$SVDRPPORT" ] && VDRCMD="$VDRCMD -p $SVDRPPORT"
+
+ for ((i=0;i<${#PLUGINS[*]};i++)) ; do
+ p="${PLUGINS[i]}"
+ if [ -n "$p" ] ; then
+ # do some shell quoting
+ p="${p//'\'/\\\\}"
+ p="${p//'\\'/\\\\}"
+ p="${p//\"/\\\"}"
+ p="${p//\$/\\\$}"
+ p="${p//\`/\\\`}"
+ VDRCMD="$VDRCMD -P \"$p\""
+ fi
+ done
+
+ if [ -n "$PLUGINSETUPCONF" ] ; then
+ ALL_PLUGINS=`< $PLUGINSETUPCONF`
+ VDRCMD="$VDRCMD $ALL_PLUGINS"
+ fi
+
+ [ -n "$RECORDCMD" ] && VDRCMD="$VDRCMD -r \"$RECORDCMD\""
+ case "$RCU" in
+ 1|"") VDRCMD="$VDRCMD --rcu";;
+ 0) ;;
+ *) VDRCMD="$VDRCMD --rcu=\"$RCU\"";;
+ esac
+ [ -n "$SHUTDOWN" ] && VDRCMD="$VDRCMD -s \"$SHUTDOWN\""
+ [ -n "$TERMINAL" ] && VDRCMD="$VDRCMD -t \"$TERMINAL\""
+ [ -n "$VDRUSER" ] && VDRCMD="$VDRCMD -u \"$VDRUSER\""
+ [ -n "$VFAT" ] && VDRCMD="$VDRCMD -v"
+ [ -n "$VIDEODIR" ] && VDRCMD="$VDRCMD -v \"$VIDEODIR\""
+ [ -n "$WATCHDOG" ] && VDRCMD="$VDRCMD -w $WATCHDOG"
+
+
+ [ -z "$TERMTIMEOUT" ] && TERMTIMEOUT=20
+ [ -z "$KILLTIMEOUT" ] && KILLTIMEOUT=5
+
+ return 0
+}
+
+function GetChilds() {
+ # Get PIDs of all forked childs of PID=$1, binary executable=$2
+ # Returns list of PIDs in childlist
+
+ child="$1"
+ childlist=($child)
+ IFSBACKUP="$IFS"
+ for ((i=0;i<10;i++)) do
+ len=${#childlist[*]}
+ IFS=","
+ child=`{ echo "$child" ; $PGREP -f "^$2 " -P "${childlist[*]}" ; } | sort -u`
+ IFS="$IFSBACKUP"
+ childlist=($child)
+
+ [ "$len" -eq "${#childlist[*]}" ] && break
+ done
+}
+
+function WaitKill() {
+ # Terminates/Kills process $1, binary $2, timeout1 $3, timeout2 $4
+
+ GetChilds "$1" "$2"
+
+ echo -n "Sending ${#childlist[*]} processes the TERM signal."
+ $KILL -TERM ${childlist[*]} >&- 2>&-
+
+ for ((i=0;i<$3;i++)) ; do
+ $PS ${childlist[*]} >&- 2>&- || { echo terminated. ; return ; }
+
+ echo -n .
+ $SLEEP 1
+ done
+ echo
+
+ echo -n "Sending ${#childlist[*]} processes the KILL signal."
+ $KILL -KILL ${childlist[*]} >&- 2>&-
+
+ for ((i=0;i<$4;i++)) ; do
+ $PS ${childlist[*]} >&- 2>&- || { echo terminated. ; return ; }
+ echo -n .
+ $SLEEP 1
+ done
+ echo failed.
+}
+
+
+
+#### ---------------
+#### Main script
+#### ---------------
+
+
+# Parse command line, step 1
+ParseCommandLine_Step1 "$@" || exit 1
+
+# Clean variables
+Clean
+
+# Load and process all configuration
+LoadConfFile || exit 1
+
+# Process command line
+ParseCommandLine_Step2 || exit 1
+
+
+if [ -n "$HELP" ] ; then
+ OnlineHelp
+ exit 0
+fi
+
+if [ -n "$VERSION" ] ; then
+ echo "runvdr version 0.1.0"
+ exit 0
+fi
+
+# Get old runvdr pid and move it to options
+if [ -n "$RUNVDRPID" ] ; then
+ OLDRUNVDRPID=""
+ [ -r "$RUNVDRPID" ] && OLDRUNVDRPID=`<$RUNVDRPID`
+
+ [ -z "$TERMINATE" ] && TERMINATE="$OLDRUNVDRPID"
+ [ -z "$RESTART" ] && RESTART="$OLDRUNVDRPID"
+ [ -z "$DVBRESTART" ] && DVBRESTART="$OLDRUNVDRPID"
+fi
+
+if [ "$TERMINATE" != "0" ] ; then
+ if [ -n "$TERMINATE" ] ; then
+ echo -n "Terminating runvdr (PID=$TERMINATE)"
+ $KILL -TERM $TERMINATE
+ while [ -z "$WAIT" ] || [ "$WAIT" -gt 0 ] ; do
+ $PS $TERMINATE >&- || { echo done ; break ; }
+ echo -n "."
+ $SLEEP 1
+ [ -n "$WAIT" ] && let WAIT=WAIT-1
+ done
+
+ echo ""
+ else
+ echo "No runvdr process to terminate."
+ fi
+ exit 0
+fi
+
+if [ "$RESTART" != "0" ] ; then
+ if [ -n "$RESTART" ] ; then
+ echo -n "Restarting runvdr (PID=$RESTART)..."
+ $KILL -USR1 $RESTART
+ echo ""
+ else
+ echo "No runvdr process to restart."
+ fi
+ exit 0
+fi
+
+if [ "$DVBRESTART" != "0" ] ; then
+ if [ -n "$DVBRESTART" ] ; then
+ echo -n "DVB-restarting runvdr (PID=$DVBRESTART)..."
+ $KILL -USR2 $DVBRESTART
+ echo ""
+ else
+ echo "No runvdr process to dvb-restart."
+ fi
+ exit 0
+fi
+
+
+# Build up VDR command
+BuildCommand || exit 1
+
+
+# Switch front console
+
+[ -n "$SWITCHTERMINAL" ] && $CHVT $SWITCHTERMINAL
+
+if [ -n "$LANGUAGE" ] ; then
+ LANG="$LANGUAGE"
+ export LANG
+fi
+
+# Remember PID of this process
+
+[ -n "$RUNVDRPID" ] && echo $$ > $RUNVDRPID
+
+
+# Prepare terminal redirection
+if [ -n "$TERMINAL" ] ; then
+ exec 1>"$TERMINAL"
+ exec 2>"$TERMINAL"
+fi
+
+
+# Load driver if it hasn't been loaded already:
+$DVBLOAD
+
+# Count how often VDR terminated very quickly
+SHORTRUNTIMES=0
+
+while (true) do
+ echo -n "Starting VDR at " ; $DATE
+
+ # Trap some signals sent to this script
+ trap "SIG=HUP" SIGHUP
+ trap "SIG=INT" SIGINT
+ trap "SIG=QUIT" SIGQUIT
+ trap "SIG=TERM" SIGTERM
+ trap "SIG=USR1" SIGUSR1
+ trap "SIG=USR2" SIGUSR2
+
+ # clean up signal variable
+ SIG=
+
+ # Remember start time
+ STARTTIME=`$DATE +%s`
+
+ echo "$VDRCMD"
+
+ # Run VDR
+ eval "$VDRCMD &"
+
+ # Remember PID of VDR process
+ PID=$!
+
+ # Wait for VDR to end or signal to arrive
+ wait $PID
+
+ # Remember return value of VDR
+ RET=$?
+
+ # Remember stop time
+ STOPTIME=`$DATE +%s`
+ # Count if time is less than 10 seconds,
+ # forget otherwise
+ if [ $((STOPTIME-STARTTIME)) -le 10 ] ; then
+ SHORTRUNTIMES=$((SHORTRUNTIMES+1))
+ echo "VDR died within 10 seconds, this happened $SHORTRUNTIMES time(s)."
+ else
+ SHORTRUNTIMES=0
+ fi
+
+ # Reset terminal status
+ [ -n "$TERMINAL" ] && $SETTERM -initialize
+
+ case "$SIG" in
+ HUP | INT | QUIT | TERM)
+ echo -n "Terminating by request at " ; $DATE
+
+ # Kill remaining VDR traces
+ WaitKill $PID $VDRPRG $TERMTIMEOUT $KILLTIMEOUT
+
+ # and exit
+ break
+ ;;
+ USR1)
+ echo -n "Restarting VDR by request at " ; $DATE
+
+ # Kill remaining VDR traces
+ WaitKill $PID $VDRPRG $TERMTIMEOUT $KILLTIMEOUT
+
+ # and loop
+ ;;
+ USR2)
+ echo -n "Restarting VDR and DVB by request at " ; $DATE
+
+ # Kill remaining VDR traces
+ WaitKill $PID $VDRPRG $TERMTIMEOUT $KILLTIMEOUT
+
+ # reload DVB stuff
+ $DVBUNLOAD
+ $DVBLOAD
+ ;;
+ *) # Non-signal termination
+ if [ $RET -eq 0 -o $RET -eq 2 ] ; then
+ echo -n "Terminating by error level $RET at " ; $DATE
+
+ # Kill remaining VDR traces
+ WaitKill $PID $VDRPRG $TERMTIMEOUT $KILLTIMEOUT
+
+ # and exit
+ break
+ fi
+ if [ $SHORTRUNTIMES -ge 5 ] ; then
+ echo -n "Terminating because VDR died 5 times in a row quickly at " ; $DATE
+
+ # Kill remaining VDR traces
+ WaitKill $PID $VDRPRG $TERMTIMEOUT $KILLTIMEOUT
+
+ # and exit
+ break;
+ fi
+ echo -n "Restarting VDR and DVB by error level $RET at " ; $DATE
+
+ # Kill remaining VDR traces
+ WaitKill $PID $VDRPRG $TERMTIMEOUT $KILLTIMEOUT
+
+ # reload DVB
+ $DVBUNLOAD
+ $DVBLOAD
+
+ # and loop
+ ;;
+ esac
+
+ # reload configuration
+ Clean
+ LoadConfFile || exit 1
+ ParseCommandLine_Step2 || exit 1
+ BuildCommand || exit 1
+
+ # Catch remaining in-between signals
+ case "$SIG" in
+ HUP | INT | QUIT | TERM)
+ break
+ ;;
+ esac
+done
+
+# Clean up PID file
+[ -n "$RUNVDRPID" ] && rm $RUNVDRPID >&- 2>&-
+
diff --git a/runvdr.conf.example b/runvdr.conf.example
new file mode 100644
index 0000000..b06572a
--- /dev/null
+++ b/runvdr.conf.example
@@ -0,0 +1,165 @@
+# runvdr.conf
+#
+# Sample configuration file for the runvdr vdr-launcher script.
+#
+# by Udo Richter <udo_richter(a)gmx.de>
+# http://www.richter-udo.de/vdr/scripts.html#runvdr
+#
+#
+
+##### -------------------------
+##### Common config options
+##### -------------------------
+
+# The VDR binary to run:
+VDRPRG="/usr/local/bin/vdr"
+
+# Command to load the DVB drivers
+# DVBLOAD will be launched before VDR starts and whenever the drivers
+# need to be reloaded.
+DVBLOAD=""
+
+# Command to unload the DVB drivers
+# DVBUNLOAD will be launched whenever the drivers need to be reloaded.
+DVBUNLOAD=""
+
+# Use VIDEODIR as video directory. The default is /video.
+VIDEODIR="/video"
+
+# Read config files from directory CONFIGDIR (default is to read them
+# from the video directory).
+CONFIGDIR="/video"
+
+
+##### -----------
+##### Plugins
+##### -----------
+
+# Load a plugin, defined by the given options. The first word in
+# options must be the name of an existing vdr plugin, optionally
+# followed by a blank separated list of command line options for
+# that plugin. If options contains any blanks, you need to enclose
+# it in quotes, like for example
+#
+# AddPlugin hello -b -a "A B C"
+#
+# which would load a plugin named "hello", giving it the three
+# command line options "-b", "-a" and "A B C"
+#
+# Note: Using the command line option --plugin requires additional
+# quoting. The corresponding command line would be:
+#
+# runvdr --plugin "hello -b -a \"A B C\""
+#
+# Add as many plugins as you want here:
+AddPlugin
+AddPlugin
+AddPlugin
+AddPlugin
+AddPlugin
+
+# Search for plugins in directory LIBDIR. Default is ./PLUGINS/lib.
+LIBDIR=
+
+# If you use PluginSetup: Where is the the plugin_setup_runvdr.conf file?
+# PLUGINSETUPCONF="$CONFIGDIR/plugins/plugin_setup_runvdr.conf"
+
+##### -----------------------
+##### More config options
+##### -----------------------
+
+# Run as user VDRUSER in case vdr was started as user 'root'. Starting vdr as
+# 'root' is necessary if the system time shall be set from the transponder
+# data, but for security reasons vdr can switch to a lesser privileged user
+# id during normal operation.
+VDRUSER=""
+
+# Write the EPG data into EPGFILE. Default is /video/epg.data.
+# Use EPGFILE=- to disable this. If EPGFILE is a directory, the file
+# epg.data will be created in that directory.
+EPGFILE=""
+
+# Call RECORDCMD before and after a recording.
+RECORDCMD=""
+
+# Call SHUTDOWN to shutdown the computer.
+SHUTDOWN=""
+
+# Send Dolby Digital audio to stdin of the command AUDIO:
+AUDIO=""
+
+# Use only the given DVB device. Set one or more DVB device numbers
+# like this: (0 1 2). Defaults to all devices.
+DVBDEVICE=()
+
+# Set logging to level. 0 = no logging, 1 = errors only,
+# 2 = errors and info, 3 = errors, info and debug. The default
+# logging level is 3. If logging should be done to LOG_LOCALn
+# instead of LOG_USER, add '.n' to LEVEL, as in 3.7 (n=0..7).
+LOGLEVEL=3
+
+# Mute audio of the primary DVB device at startup. Set to anything
+# to mute, keep clear for not.
+MUTE=
+
+# Use SVDRPPORT port for SVDRP. A value of 0 turns off SVDRP. The default
+# SVDRP port is 2001. You need to edit the file svdrphosts.conf
+# in order to enable access to the SVDRP port.
+SVDRPPORT=
+
+# Activate the watchdog timer with a timeout of sec seconds. A
+# value of 0 (default) disables the watchdog.
+WATCHDOG=90
+
+# Run in daemon mode (implies NOKBD=1)
+# Set to anything to activate:
+DAEMON=
+
+# Write images from the SVDRP command GRAB into the given directory.
+# GRAB must be the full path name of an existing directory, without
+# any "..", double '/' or symlinks. By default, or if GRAB=- is given,
+# grabbing images to disk is disabled.
+GRAB=
+
+# Use a LIRC remote control device. If set to 1, vdr uses /dev/lircd.
+# If not set, or set to 0, don't use LIRC.
+LIRC=
+
+# Don't use the keyboard as an input device. Set to anything.
+NOKBD=
+
+# Use a serial port remote control device. If set to 1, vdr uses /dev/ttyS1.
+# If not set, or set to 0, don't use rcu.
+RCU=
+
+# encode special characters in recording names to avoid problems
+# with VFAT file systems
+VFAT=
+
+# Store PID of runvdr into a file?
+RUNVDRPID=/var/run/runvdr.pid
+
+# Set the controlling terminal. For example, /dev/tty8
+TERMINAL=/dev/tty8
+
+# Switch console to some terminal? Needs terminal number.
+# For example, SWITCHTERMINAL=8
+SWITCHTERMINAL=8
+
+# Set language for locale to run VDR on.
+# This affects sort options in recordings.
+# LANGUAGE="de_DE@euro"
+
+# Additional parameters to pass to VDR directly, without parsing:
+ADDPARAM=""
+
+# Command wrapper. Will be placed in front of the VDR command.
+# Example:
+# WRAPPER="gdb --args"
+# WRAPPER="valgrind"
+WRAPPER=
+
+# Timeouts for SIGTERM and SIGKILL when stopping VDR
+# TERMTIMEOUT defaults to 20 secods, KILLTIMEOUT to 5 seconds
+TERMTIMEOUT=
+KILLTIMEOUT=