3 # runvdr - VDR launcher
5 # runvdr [VDROPTION]...
7 shopt -s extglob nocasematch nullglob
10 PLUGINDIR
=/usr
/lib
/vdr
11 PLUGINVER
=VDR_PLUGIN_VERSION
12 PLUGINSUF
=${PLUGINVER:+.$PLUGINVER}
16 type -P logger
&>/dev
/null
&& \
17 logger
-s -p daemon.info
-t ${0##*/} "$1" 2>&1 ||
echo "INFO: $1"
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
27 if [[ $PLUGIN_OPTIONS ]] ; then
28 VDR_OPTIONS
+=( --plugin="$plugin $PLUGIN_OPTIONS" )
30 VDR_OPTIONS
+=( --plugin=$plugin )
37 # Add "priority" plugins.
38 for plugin
in $VDR_PLUGIN_ORDER ; do
39 [[ -e $PLUGINDIR/libvdr-
${plugin}.so
$PLUGINSUF ]] && plugconf
$plugin
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
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
70 # Check timestamp set by shutdown script.
71 local nexttimer
=$
( cat /var
/run
/vdr
/next-timer
2>/dev
/null
)
72 rm -f /var
/run
/vdr
/next-timer
74 if [[ $nexttimer != +([0-9]) ]] ; then
75 # Next timer timestamp not set by shutdown script or bogus,
76 # try to get it via SVDRP.
77 nexttimer
=$
( svdrpsend NEXT abs
2>/dev
/null | \
78 sed -rne 's/^250[[:space:]]+[0-9]+[[:space:]]+([0-9]+).*/\1/p' )
81 if [[ $nexttimer && $nexttimer -gt $
( date +%s
) ]] ; then
82 [[ -f /etc
/sysconfig
/vdr
]] && .
/etc
/sysconfig
/vdr
83 local when
=$
(( $nexttimer - ${WAKEUP_BEFORE_RECORDING:-10} * 60 ))
84 local hrwhen
=$
( date -d "1970-01-01 $when sec UTC" )
85 log
"Setting wakeup time for next recording: $hrwhen"
86 /usr
/sbin
/rtcwake
-m no
-t $when >/dev
/null
90 if [[ $1 == --set-wakeup ]] ; then
91 # Just set RTC wakeup for next timer event.
100 if [[ $VDR_INIT ]] ; then
101 [[ -f /etc
/sysconfig
/vdr
]] && .
/etc
/sysconfig
/vdr
102 [[ $DAEMON_COREFILE_LIMIT ]] && \
103 ulimit -S -c $DAEMON_COREFILE_LIMIT &>/dev
/null
&& \
104 VDR_OPTIONS
+=( --userdump ) && cd ${TMPDIR:-/tmp}
108 $VDR "$@" "${VDR_OPTIONS[@]}"
111 # 137: "kill -KILL" eg in killproc(), others: "man vdr"
114 log
"VDR exited with status $rc, exiting"
118 log
"VDR exited with status $rc, attempting restart"
119 case $RELOAD_DVB in yes|true|
1) reload_dvb
;; esac