[vdr] Handle restarting with systemd instead of runvdr

Ville Skyttä scop at fedoraproject.org
Tue Jan 7 21:54:41 UTC 2014


commit ca956af711b48089ac9592bced9645070642eb80
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Mon Jan 6 23:47:42 2014 +0200

    Handle restarting with systemd instead of runvdr
    
    I couldn't find a clean way to reload DVB modules any more with this
    scenario and the feature is sketchy anyway, so it is gone now.

 vdr-check-setup.sh |    2 +-
 vdr-runvdr.sh      |   48 +++++++-----------------------------------------
 vdr.service        |    3 ++-
 vdr.spec           |    2 ++
 vdr.sysconfig      |    4 ----
 5 files changed, 12 insertions(+), 47 deletions(-)
---
diff --git a/vdr-check-setup.sh b/vdr-check-setup.sh
index bffddf1..93f1ba3 100644
--- a/vdr-check-setup.sh
+++ b/vdr-check-setup.sh
@@ -3,7 +3,7 @@
 cfg=/etc/vdr/channels.conf
 if [ ! -s $cfg ] ; then
     echo "$cfg is not valid, use \"scandvb -o vdr\" from the dvb-apps package to create one." >&2
-    exit 6
+    exit 2
 else
     chown VDR_USER:VDR_GROUP $cfg && chmod 644 $cfg
 fi
diff --git a/vdr-runvdr.sh b/vdr-runvdr.sh
index 5bdea34..37cff36 100644
--- a/vdr-runvdr.sh
+++ b/vdr-runvdr.sh
@@ -46,46 +46,12 @@ build_cmdline()
     done
 }
 
-reload_dvb()
-{
-    local modules=$( /sbin/lsmod | \
-        awk '/^dvb_core/ { gsub(","," ",$4) ; print $4 }' )
-    if [[ $modules ]] ; then
-        echo "Reloading DVB modules"
-        /sbin/modprobe -r $modules dvb_core
-        for module in $modules ; do
-            /sbin/modprobe $module
-        done
-    fi
-}
-
-rc=
-while true ; do
-
-    VDR_OPTIONS=()
-    if [[ $VDR_INIT ]] ; then
-        [[ -f /etc/sysconfig/vdr ]] && . /etc/sysconfig/vdr
-        [[ $DAEMON_COREFILE_LIMIT ]] && \
-            ulimit -S -c $DAEMON_COREFILE_LIMIT &>/dev/null && \
-            VDR_OPTIONS+=( --userdump ) && cd ${TMPDIR:-/tmp}
-        build_cmdline
-    fi
-
-    $VDR "$@" "${VDR_OPTIONS[@]}"
-    rc=$?
-
-    # 137: "kill -KILL" eg in killproc(), others: "man vdr"
-    case $rc in
-        0|2|137)
-            echo "VDR exited with status $rc, exiting"
-            break
-            ;;
-        *)
-            echo "VDR exited with status $rc, attempting restart" >&2
-            case $RELOAD_DVB in yes|true|1) reload_dvb ;; esac
-            ;;
-    esac
+VDR_OPTIONS=()
+[[ -f /etc/sysconfig/vdr ]] && . /etc/sysconfig/vdr
+[[ $DAEMON_COREFILE_LIMIT ]] && \
+    ulimit -S -c $DAEMON_COREFILE_LIMIT &>/dev/null && \
+    VDR_OPTIONS+=( --userdump ) && cd ${TMPDIR:-/tmp}
 
-done
+build_cmdline
 
-exit $rc
+exec $VDR "$@" "${VDR_OPTIONS[@]}"
diff --git a/vdr.service b/vdr.service
index c1e9e66..fa47fe6 100644
--- a/vdr.service
+++ b/vdr.service
@@ -5,10 +5,11 @@ Documentation=file:///usr/share/doc/vdr/INSTALL
 After=network.target lirc.service
 
 [Service]
-Environment=VDR_INIT=1
 ExecStartPre=/usr/lib/vdr/bin/vdr-check-setup
 ExecStart=/usr/sbin/runvdr
 ExecStop=-/usr/lib/vdr/bin/vdr-set-wakeup
+Restart=on-failure
+RestartPreventExitStatus=2
 
 [Install]
 WantedBy=multi-user.target
diff --git a/vdr.spec b/vdr.spec
index c439eb0..afbd33d 100644
--- a/vdr.spec
+++ b/vdr.spec
@@ -551,6 +551,8 @@ useradd -r -g %{vdr_group} -d %{vardir} -s /sbin/nologin -M -N \
 
 %changelog
 * Mon Jan  6 2014 Ville Skyttä <ville.skytta at iki.fi>
+- Remove restart logic from runvdr, handle it with systemd instead.
+- Drop DVB reloading logic due to the above change.
 - Use stdout/err for script log messages and let systemd route them.
 - Get locale settings from /etc/locale.conf, not /etc/sysconfig/i18n.
 - Use systemd macros in scriptlets (#850358).
diff --git a/vdr.sysconfig b/vdr.sysconfig
index 0dd5761..137a235 100644
--- a/vdr.sysconfig
+++ b/vdr.sysconfig
@@ -60,10 +60,6 @@ PATH="/usr/lib/vdr/bin:$PATH"
 #
 WAKEUP_BEFORE_RECORDING=10
 
-# Try reloading DVB modules on unexpected exits?
-#
-#RELOAD_DVB=yes
-
 # For debugging: allow vdr to dump core.  Note that depending on the operating
 # environment, core dumps from setuid processes may be a security issue.
 #


More information about the scm-commits mailing list