From: Andrew Ruthven Date: Mon, 31 Dec 2018 08:53:38 +0000 (+1300) Subject: Ship a systemd service file X-Git-Tag: 1.0.0~26 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=785d499f82027088f5da8fe88c08689f63d46a32;p=mythtv-status.git Ship a systemd service file --- diff --git a/ChangeLog b/ChangeLog index 3b316e9..a2394c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-12-31 Andrew Ruthven + Ship a systemd service file which correctly starts and stops the motd + update services. As part of this change, if you use systemd or sysvinit + to stop mythtv-status it will stop updating the motd snippet via cron. + 2018-12-30 Andrew Ruthven Modify mythtv-update-motd to look to see if /etc/update-motd.d is present, if it is, then generate MOTD content in a compatible fashion. diff --git a/bin/mythtv-update-motd b/bin/mythtv-update-motd index 11c5815..0e3d38c 100755 --- a/bin/mythtv-update-motd +++ b/bin/mythtv-update-motd @@ -8,7 +8,7 @@ TEMPFILE=/var/run/motd.mythtv-status . /etc/default/mythtv-status -if [ x$RUN != xyes ] +if [ x$RUN != xyes -o -f /var/lib/mythtv-status/motd_update_disabled ] then exit fi diff --git a/debian/changelog b/debian/changelog index ae8e759..08e90c9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ mythtv-status (1.0.0-1) UNRELEASED; urgency=medium * New upstream release (Closes: #853857). * Install a snippet into /etc/update-motd.d (Closes: #902684). * Update standards version to 4.3.0. + * Ship a systemd service file (Closes: #772801) -- Andrew Ruthven Mon, 12 Nov 2018 23:19:17 +1300 diff --git a/debian/dirs b/debian/dirs index e772481..6f498a6 100644 --- a/debian/dirs +++ b/debian/dirs @@ -1 +1,2 @@ usr/bin +var/lib/mythtv-status diff --git a/debian/init.d b/debian/init.d index 6c8e951..f4a1222 100644 --- a/debian/init.d +++ b/debian/init.d @@ -36,6 +36,7 @@ NAME=mythtv-status # Introduce the short server's name here DESC="MythTV Status" # Introduce a short description here TEMPFILE=/var/run/motd.mythtv-status WORKFILE=/var/run/motd +DISABLED_FLAG=/var/lib/mythtv-status/motd_update_disabled test -x $DAEMON || exit 0 @@ -63,6 +64,7 @@ case "$1" in start|reload|refresh|restart|force-reload) log_daemon_msg "Updating $DESC" "$NAME" + rm $DISABLED_FLAG if ! /usr/sbin/mythtv-update-motd; then log_failure_msg "Failed to update MOTD" exit 1 @@ -73,12 +75,17 @@ case "$1" in ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" + touch $DISABLED_FLAG [ -f /var/run/motd.orig ] && cp /var/run/motd.orig $WORKFILE rm /var/run/motd.orig 2> /dev/null || true rm $TEMPFILE 2> /dev/null || true log_end_msg 0 ;; status) + if [ -f $DISABLED_FLAG ]; then + log_failed "$NAME is not running (disabled by flag file: $DISABLED_FLAG)" + exit 1 + fi if [ ! -f $WORKFILE ]; then log_failure_msg "$NAME is not running (no motd file)!" exit 1 diff --git a/debian/mythtv-status.service b/debian/mythtv-status.service new file mode 100644 index 0000000..882cf8f --- /dev/null +++ b/debian/mythtv-status.service @@ -0,0 +1,15 @@ +[Unit] +Description=MythTV Status +After=network.target mythtv-backend.service +Wants=mythtv-backend.service +Documentation=man:mythtv-status + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=/bin/sh -c "rm /var/lib/mythtv-status/motd_update_disabled || true" +ExecStart=/usr/sbin/mythtv-update-motd +ExecStop=/bin/sh -c "touch /var/lib/mythtv-status/motd_update_disabled; rm /run/motd.mythtv-status || true"; + +[Install] +WantedBy=multi-user.target diff --git a/man/mythtv-update-motd.1 b/man/mythtv-update-motd.1 index d0d88b6..1864ed3 100644 --- a/man/mythtv-update-motd.1 +++ b/man/mythtv-update-motd.1 @@ -2,7 +2,7 @@ .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) -.TH MYTHTV-UPDATE-MOTD 1 "2015-01-11" +.TH MYTHTV-UPDATE-MOTD 1 "2018-12-31" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -16,15 +16,37 @@ .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME -mythtv-update-motd \- update the MOTD with the MythTV backend status +mythtv-update-motd \- update the MOTD with a MythTV backend status .SH SYNOPSIS .B mythtv-update-motd .SH DESCRIPTION -.B mythtv-update-motd -Update the system MOTD with the status of the MythTV backend. -It checks the host which is configured in +Update the system MOTD with the status of a MythTV backend. It is +typically run from cron. +.SH CONFIGURATION +The configuration file for this script is .I /etc/default/mythtv-status -with the HOST setting. +options of interest: +.TP +.B HOST +The host to check, by default this is localhost. +.TP +.B RUN +Should this script run? Set to yes to enable, anything else to disable. +.PP +.PD 0 +You can also disable this script from running by creating a file +called +.IR /var/lib/mythtv-status/motd_update_disabled . +If you run either: +.IP +systemctl stop mythtv-status +.PP +or +.IP +/etc/init.d/mythtv-status stop +.PP +this will be done for you, and will remove the most recent motd snippet. +.PD .SH OPTIONS None .SH "EXIT STATUS"