From a968e49bd73e9be8ca0734a5ee36c73a582e33e4 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sun, 16 Jul 2023 01:11:17 +1200 Subject: [PATCH] Install systemd services and timers for regular tasks --- debian/changelog | 1 + debian/cron.daily | 10 ++-------- debian/dirs | 1 + debian/health-check | 21 +++++++++++++++++++++ debian/install | 7 ++++++- debian/mythtv-status_health-check.service | 7 +++++++ debian/mythtv-status_health-check.timer | 10 ++++++++++ debian/mythtv-status_update-motd.service | 7 +++++++ debian/mythtv-status_update-motd.timer | 10 ++++++++++ debian/rules | 7 +++++++ 10 files changed, 72 insertions(+), 9 deletions(-) create mode 100755 debian/health-check create mode 100644 debian/mythtv-status_health-check.service create mode 100644 debian/mythtv-status_health-check.timer create mode 100644 debian/mythtv-status_update-motd.service create mode 100644 debian/mythtv-status_update-motd.timer diff --git a/debian/changelog b/debian/changelog index fe98ee4..355d37a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,7 @@ mythtv-status (1.0.2-1) UNRELEASED; urgency=medium * Drop versioned dependency on molly-guard, 0.4 was released in 2008. * Move libmythtv-perl to by a Suggests, as it is doesn't exist in the official Debian repo. + * Install systemd services and timers for regular tasks. -- Andrew Ruthven Sun, 06 Dec 2020 22:51:12 +1300 diff --git a/debian/cron.daily b/debian/cron.daily index 5bab4e9..34cc283 100644 --- a/debian/cron.daily +++ b/debian/cron.daily @@ -1,13 +1,7 @@ #!/bin/sh -. /etc/default/mythtv-status - -if [ "x$EMAIL" = "x" -o "x$EMAIL" = "xnone" ] -then - exit -fi - -/usr/bin/mythtv-status --host $HOST --email $EMAIL $EMAIL_ARGS +[ -x /usr/lib/mythtv-status/health-check ] \ + && /usr/local/mythtv-status/health-check # Keep run-parts happy by always returning with a return code of 0. exit 0 diff --git a/debian/dirs b/debian/dirs index 6f498a6..6f402eb 100644 --- a/debian/dirs +++ b/debian/dirs @@ -1,2 +1,3 @@ usr/bin +usr/libexec/mythtv-status var/lib/mythtv-status diff --git a/debian/health-check b/debian/health-check new file mode 100755 index 0000000..39e739c --- /dev/null +++ b/debian/health-check @@ -0,0 +1,21 @@ +#!/bin/sh +# Copyright (c) 2007-2023 Andrew Ruthven +# This code is hereby licensed for public consumption under the GNU GPL v3. +# +# 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., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# Run mythtv-status to perform a health check of the MythTV system. + +. /etc/default/mythtv-status + +if [ "$EMAIL" = "" ] || [ "$EMAIL" = "none" ] +then + exit +fi + +/usr/bin/mythtv-status --host "$HOST" --email "$EMAIL" "$EMAIL_ARGS" + +# Keep things happy by always having a return code of 0. +exit 0 diff --git a/debian/install b/debian/install index e9c997b..741d319 100644 --- a/debian/install +++ b/debian/install @@ -1,4 +1,9 @@ bin/mythtv-update-motd /usr/sbin +debian/health-check usr/libexec/mythtv-status +debian/lintian/overrides/mythtv-status usr/share/lintian/overrides +debian/mythtv-status_health-check.service lib/systemd/system +debian/mythtv-status_health-check.timer lib/systemd/system +debian/mythtv-status_update-motd.service lib/systemd/system +debian/mythtv-status_update-motd.timer lib/systemd/system molly-guard/40-mythtv-recording-soon etc/molly-guard/run.d update-motd.d/50-mythtv-status etc/update-motd.d -debian/lintian/overrides/mythtv-status usr/share/lintian/overrides diff --git a/debian/mythtv-status_health-check.service b/debian/mythtv-status_health-check.service new file mode 100644 index 0000000..6948fa8 --- /dev/null +++ b/debian/mythtv-status_health-check.service @@ -0,0 +1,7 @@ +[Unit] +Description=Daily mythtv-status health check of MythTV +Documentation=man:mythtv-status(1) + +[Service] +Type=oneshot +ExecStart=/usr/lib/mythtv-status/health-check diff --git a/debian/mythtv-status_health-check.timer b/debian/mythtv-status_health-check.timer new file mode 100644 index 0000000..f169d7e --- /dev/null +++ b/debian/mythtv-status_health-check.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Daily mythtv-status health check of MythTV +Documentation=man:mythtv-status(1) + +[Timer] +OnCalendar=Daily +OnBootSec=15min + +[Install] +WantedBy=timers.target diff --git a/debian/mythtv-status_update-motd.service b/debian/mythtv-status_update-motd.service new file mode 100644 index 0000000..c044662 --- /dev/null +++ b/debian/mythtv-status_update-motd.service @@ -0,0 +1,7 @@ +[Unit] +Description=mythtv-status MOTD update +Documentation=man:mythtv-update-motd(1) + +[Service] +Type=oneshot +ExecStart=/usr/sbin/mythtv-update-motd diff --git a/debian/mythtv-status_update-motd.timer b/debian/mythtv-status_update-motd.timer new file mode 100644 index 0000000..09dfcd9 --- /dev/null +++ b/debian/mythtv-status_update-motd.timer @@ -0,0 +1,10 @@ +[Unit] +Description=mythtv-status MOTD update +Documentation=man:mythtv-update-motd(1) + +[Timer] +OnCalendar=*-*-* *:00,15,30,45 +OnBootSec=60 + +[Install] +WantedBy=timers.target diff --git a/debian/rules b/debian/rules index 218df65..4380aee 100755 --- a/debian/rules +++ b/debian/rules @@ -6,3 +6,10 @@ %: dh $@ + +override_dh_installsystemd: + dh_installsystemd mythtv-status.service \ + mythtv-status_health-check.service \ + mythtv-status_health-check.timer \ + mythtv-status_update-motd.service \ + mythtv-status_update-motd.timer -- 2.30.2