diff options
author | 2014-01-19 15:44:19 +0100 | |
---|---|---|
committer | 2014-01-19 15:44:19 +0100 | |
commit | 7f33e88a09bf7a30b6289e51af0f3a43db76d4b4 (patch) | |
tree | b22153bb1e9379ce3d405ed7b8f6b1d47410ae3e | |
parent | removed useless/unusable sudoers check, reported by Lucian Muresan (diff) | |
download | gentoo-vdr-scripts-7f33e88a09bf7a30b6289e51af0f3a43db76d4b4.tar.gz gentoo-vdr-scripts-7f33e88a09bf7a30b6289e51af0f3a43db76d4b4.tar.bz2 gentoo-vdr-scripts-7f33e88a09bf7a30b6289e51af0f3a43db76d4b4.zip |
added systemd service file, systemd helper script; wrt bug 353492
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | usr/lib/systemd/system/vdr.service | 36 | ||||
-rw-r--r-- | usr/share/vdr/bin/vdr-systemd_helper.sh | 106 |
3 files changed, 147 insertions, 0 deletions
@@ -1,6 +1,11 @@ # ChangeLog for gentoo-vdr-scripts # $Id$ + 19 Jan 2014; Joerg Bornkessel <hd_brummy@gentoo.org> + +usr/lib/systemd/system/vdr.service, + +usr/share/vdr/bin/vdr-systemd_helper.sh: + added systemd service file, systemd helper script + 06 Jan 2014; Joerg Bornkessel <hd_brummy@gentoo.org> usr/share/vdr/rcscript/pre-start-50-shutdown.sh: removed useless/unusable sudoers check, reported by Lucian Muresan diff --git a/usr/lib/systemd/system/vdr.service b/usr/lib/systemd/system/vdr.service new file mode 100644 index 0000000..18ae76f --- /dev/null +++ b/usr/lib/systemd/system/vdr.service @@ -0,0 +1,36 @@ +[Unit] +Description=Video Disk Recorder Daemon +After=systemd-udevd.service lirc.service +Requires=systemd-udevd.service +DefaultDependencies=no + + +[Service] +User=vdr +# this will collect the parameters and set them into the VDR_OPTS +# variable in the EnvironmentFile +ExecStartPre=/usr/share/vdr/bin/vdr-systemd_helper.sh --start-pre + + +# this is where we get our parameters (still manageable +# in the /etc/conf.d/vdr.* files +EnvironmentFile=/var/vdr/tmp/systemd_env + +# start VDR with our desired parameters, please disable the +# internal watchdog by setting the timeout to 0 +ExecStart=/usr/bin/vdr $VDR_OPTS + +# execute addons/plugins scripts meant to be run afer starting +ExecStartPost=/usr/share/vdr/bin/vdr-systemd_helper.sh --start-post + +# execute addons/plugins scripts meant to be run before stopping +ExecStop=/usr/share/vdr/bin/vdr-systemd_helper.sh --stop-pre + +# execute final scripts +ExecStopPost=/usr/share/vdr/bin/vdr-systemd_helper.sh --stop-post + +Restart=always + + +[Install] +WantedBy=multi-user.target diff --git a/usr/share/vdr/bin/vdr-systemd_helper.sh b/usr/share/vdr/bin/vdr-systemd_helper.sh new file mode 100644 index 0000000..14ab6b8 --- /dev/null +++ b/usr/share/vdr/bin/vdr-systemd_helper.sh @@ -0,0 +1,106 @@ +#!/bin/sh + +# VDR helper script for using a systemd unit together +# with media-tv/gentoo-vdr-scripts +# +# Copyright 1999-2014, Lucian Muresan < lucianm AT users DOT sourceforge DOT net > +# inspired by the old OpenRC script /etc/init.d/vdr by Mathias Schwarzott + +# Distributed under the terms of the GNU General Public License v2 + +# read our main options +. /etc/conf.d/vdr +. /etc/conf.d/vdr.watchdogd + +# inspired by the old OpenRC script /etc/init.d/vdr: +cd /var/vdr +unset MAIL +. /usr/share/vdr/inc/functions.sh +include rc-functions +include plugin-functions +init_tmp_dirs +VDR_LOG_FILE="${PL_TMP}/vdr-start-log" +# this is the environment file to pass user and parameters to the systemd unit file +SYSTEMD_ENV_FILE="${PL_TMP}/systemd_env" + +#common_init + +# dummy functions to make the rest of gentoo-vdr-scripts happy, +# as we do not want to rely on openrc's implementations of these +# commands: +ebegin() { + vdr_log "ACTION: $@" +} + +eend() { + vdr_log "RESULT: $@" +} + +ewarn() { + vdr_log "WARN: $@" +} + +einfo() { + vdr_log "INFO: $@" +} + + +# some additional logging functions +eerror() { + vdr_log "ERROR: $@" +} + +eexitfail() { + eerror "$@" + exit 1 +} + + +clear_logfile() { + rm -f "${VDR_LOG_FILE}" + printf "" > "${VDR_LOG_FILE}" +} + +# +# Used to log error-messages in startscript to show them on +# OSD later when choosing apropriate point in commands. +# + +vdr_log() +{ + echo "$@" >> "${VDR_LOG_FILE}" +} + +# +# +# Depending on $1, we execute the scripts needed +# before/after starting, or before/after stopping VDR, +# and exit with non-zero error code on failure, in such +# way that the systemd unit will fail and the problems +# have to be investigated in logs, journal, or even +# by executing these parts of the script manually in +# the console as user 'vdr' +if [ "$1" = "--start-pre" ]; then + ebegin "--start-pre" + clear_logfile + init_params + init_plugin_loader start || eexitfail "init_plugin_loader start" + load_addons_prefixed pre-start || eexitfail "load_addons_prefixed pre-start" + # these options are what we need to start VDR from the systemd unit file + echo "VDR_OPTS=\"${vdr_opts}\"" > ${SYSTEMD_ENV_FILE} + sync + eend "--start-pre" +elif [ "$1" = "--start-post" ]; then + ebegin "--start-post" + load_addons_prefixed post-start || eexitfail "load_addons_prefixed post-start" + eend "--start-post" +elif [ "$1" = "--stop-pre" ]; then + ebegin "--stop-pre" + init_plugin_loader stop || eexitfail "init_plugin_loader stop" + load_addons_prefixed pre-stop || eexitfail "load_addons_prefixed pre-stop" + eend "--stop-pre" +elif [ "$1" = "--stop-post" ]; then + ebegin "--stop-post" + load_addons_prefixed post-stop || eexitfail "load_addons_prefixed post-stop" + eend "--stop-post" +fi |