]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - config/vdr/runvdr
Forward Firewall: some language changes de.pl and en.pl as well as forwardfw.cgi...
[people/teissler/ipfire-2.x.git] / config / vdr / runvdr
CommitLineData
e20d949d
MT
1#!/bin/bash
2
3# runvdr - VDR launcher
4#
5# runvdr [VDROPTION]...
6
7shopt -s extglob nocasematch nullglob
8
9VDR=/usr/sbin/vdr
10PLUGINDIR=/usr/lib/vdr
11PLUGINVER=VDR_PLUGIN_VERSION
12PLUGINSUF=${PLUGINVER:+.$PLUGINVER}
13
14log()
15{
16 type -P logger &>/dev/null && \
17 logger -s -p daemon.info -t ${0##*/} "$1" 2>&1 || echo "INFO: $1"
18}
19
20plugconf()
21{
22 local plugin=$1 PLUGIN_OPTIONS= PLUGIN_ENABLED=
23 if [[ -e /etc/sysconfig/vdr-plugins.d/$plugin.conf ]] ; then
24 . /etc/sysconfig/vdr-plugins.d/$plugin.conf
25 case $PLUGIN_ENABLED in no|false|0) return ;; esac
26 fi
27 if [[ $PLUGIN_OPTIONS ]] ; then
28 VDR_OPTIONS+=( --plugin="$plugin $PLUGIN_OPTIONS" )
29 else
30 VDR_OPTIONS+=( --plugin=$plugin )
31 fi
32}
33
34build_cmdline()
35{
36 local plugin= p=
37 # Add "priority" plugins.
38 for plugin in $VDR_PLUGIN_ORDER ; do
39 [[ -e $PLUGINDIR/libvdr-${plugin}.so$PLUGINSUF ]] && plugconf $plugin
40 done
41 # Add the rest available.
42 for plugin in $PLUGINDIR/libvdr-*.so$PLUGINSUF ; do
43 plugin=${plugin##*/libvdr-}
44 plugin=${plugin%.so$PLUGINSUF}
45 for p in $VDR_PLUGIN_ORDER ; do
46 if [[ $plugin == $p ]] ; then
47 # Already added.
48 continue 2
49 fi
50 done
51 plugconf $plugin
52 done
53}
54
55reload_dvb()
56{
57 local modules=$( /sbin/lsmod | \
58 awk '/^dvb_core/ { gsub(","," ",$4) ; print $4 }' )
59 if [[ $modules ]] ; then
60 log "Reloading DVB modules"
61 /sbin/modprobe -r $modules dvb_core
62 for module in $modules ; do
63 /sbin/modprobe $module
64 done
65 fi
66}
67
e20d949d
MT
68rc=
69while true ; do
e20d949d 70 VDR_OPTIONS=()
90dc87b7
MT
71 [[ -f /etc/sysconfig/vdr ]] && . /etc/sysconfig/vdr
72 [[ $DAEMON_COREFILE_LIMIT ]] && \
73 ulimit -S -c $DAEMON_COREFILE_LIMIT &>/dev/null && \
74 VDR_OPTIONS+=( --userdump ) && cd ${TMPDIR:-/tmp}
75 build_cmdline
e20d949d
MT
76
77 $VDR "$@" "${VDR_OPTIONS[@]}"
78 rc=$?
79
80 # 137: "kill -KILL" eg in killproc(), others: "man vdr"
81 case $rc in
82 0|2|137)
83 log "VDR exited with status $rc, exiting"
84 break
85 ;;
86 *)
87 log "VDR exited with status $rc, attempting restart"
88 case $RELOAD_DVB in yes|true|1) reload_dvb ;; esac
89 ;;
90 esac
91
92done
93
94exit $rc