From c0f8d0b2ed176509ab4dbeb01dce5f8aadc78666 Mon Sep 17 00:00:00 2001 From: Jason Green Date: Fri, 8 Dec 2017 00:20:13 +0000 Subject: [PATCH] Update for systemd --- sources => .update-motd.metadata | 0 Makefile | 25 ------------------------- {srpm => SOURCES}/.gitignore | 0 {srpm => SOURCES}/cron_update-motd | 2 +- {srpm => SOURCES}/sbin_update-motd | 0 SOURCES/update-motd.service | 11 +++++++++++ {srpm => SOURCES}/yum_update-motd.conf | 0 {srpm => SOURCES}/yum_update-motd.py | 0 {srpm => SPECS}/update-motd.spec | 20 +++++++++++++------- srpm/upstart_update-motd.conf | 2 -- 10 files changed, 25 insertions(+), 35 deletions(-) rename sources => .update-motd.metadata (100%) delete mode 100644 Makefile rename {srpm => SOURCES}/.gitignore (100%) rename {srpm => SOURCES}/cron_update-motd (69%) rename {srpm => SOURCES}/sbin_update-motd (100%) create mode 100644 SOURCES/update-motd.service rename {srpm => SOURCES}/yum_update-motd.conf (100%) rename {srpm => SOURCES}/yum_update-motd.py (100%) rename {srpm => SPECS}/update-motd.spec (83%) delete mode 100644 srpm/upstart_update-motd.conf diff --git a/sources b/.update-motd.metadata similarity index 100% rename from sources rename to .update-motd.metadata diff --git a/Makefile b/Makefile deleted file mode 100644 index 0b38c5c..0000000 --- a/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# -*- Makefile -*- -# Makefile for source package: update-motd -# -# Module created by 'ajorgens' on 2011-07-21 - -NAME := update-motd -VENDOR := GOBI - -define find-makefile-common -$(firstword $(foreach d,. common ../common,$(if $(wildcard $(d)/Makefile.common),$(d)/Makefile.common))) -endef - -include $(find-makefile-common) - -ifeq ($(find-makefile-common),) -define get_common_url -$(shell git remote show -n origin | sed -re '/fetch\s+url/I!d;s,^.+\b(\w+://\S+)/[^/]+$$,\1/common.git,') -endef - -common : - git clone $(get_common_url) $@ - -sources :: common - $(MAKE) $@ -endif diff --git a/srpm/.gitignore b/SOURCES/.gitignore similarity index 100% rename from srpm/.gitignore rename to SOURCES/.gitignore diff --git a/srpm/cron_update-motd b/SOURCES/cron_update-motd similarity index 69% rename from srpm/cron_update-motd rename to SOURCES/cron_update-motd index 9c7899c..d11f526 100755 --- a/srpm/cron_update-motd +++ b/SOURCES/cron_update-motd @@ -1,4 +1,4 @@ # Delay a random time between 0 and 360 minutes (6 hours) to avoid having all # instances update at the same time. RANDOM_DELAY=360 -@daily root /sbin/start --quiet update-motd +@daily root /usr/bin/systemctl --quiet restart update-motd diff --git a/srpm/sbin_update-motd b/SOURCES/sbin_update-motd similarity index 100% rename from srpm/sbin_update-motd rename to SOURCES/sbin_update-motd diff --git a/SOURCES/update-motd.service b/SOURCES/update-motd.service new file mode 100644 index 0000000..01082b8 --- /dev/null +++ b/SOURCES/update-motd.service @@ -0,0 +1,11 @@ +[Unit] +Description=Dynamically Generate Message Of The Day +After=network-online.target + +[Service] +Type=oneshot +ExecStart=/usr/sbin/update-motd +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/srpm/yum_update-motd.conf b/SOURCES/yum_update-motd.conf similarity index 100% rename from srpm/yum_update-motd.conf rename to SOURCES/yum_update-motd.conf diff --git a/srpm/yum_update-motd.py b/SOURCES/yum_update-motd.py similarity index 100% rename from srpm/yum_update-motd.py rename to SOURCES/yum_update-motd.py diff --git a/srpm/update-motd.spec b/SPECS/update-motd.spec similarity index 83% rename from srpm/update-motd.spec rename to SPECS/update-motd.spec index 94ed20a..88f36d2 100644 --- a/srpm/update-motd.spec +++ b/SPECS/update-motd.spec @@ -7,11 +7,12 @@ Group: System Environment/Base BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch Requires: bash coreutils -Requires: upstart +BuildRequires: systemd-devel +%{?systemd_requires} Source0: sbin_update-motd Source1: cron_update-motd -Source2: upstart_update-motd.conf +Source2: update-motd.service Source3: yum_update-motd.py Source4: yum_update-motd.conf @@ -24,7 +25,7 @@ rm -rf %{buildroot} install -d %{buildroot}/etc/update-motd.d install -D -m 0755 %{SOURCE0} %{buildroot}/usr/sbin/update-motd install -D -m 0644 %{SOURCE1} %{buildroot}/etc/cron.d/update-motd -install -D -m 0644 %{SOURCE2} %{buildroot}/etc/init/update-motd.conf +install -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/update-motd.service install -D -m 0644 %{SOURCE3} %{buildroot}/usr/lib/yum-plugins/update-motd.py install -D -m 0644 %{SOURCE4} %{buildroot}/etc/yum/pluginconf.d/update-motd.conf # for %ghost @@ -51,16 +52,21 @@ elif [ "$1" = "2" ]; then ln -snf /var/lib/update-motd/motd /etc/motd fi fi -# We don't run update-motd on install because the various update-motd.d scripts -# are not installed yet (since their packages will depend on this one). -# This could also be the case in an upgrade situation, so we leave it to cron. +%systemd_post update-motd.service sshd.socket + +%preun +%systemd_preun update-motd.service sshd.socket + +%postun +%systemd_postun_with_restart update-motd.service + %files %defattr(-,root,root,-) %dir /etc/update-motd.d %dir /var/lib/update-motd %config /etc/cron.d/update-motd -%config /etc/init/update-motd.conf +%config %{_unitdir}/update-motd.service %config /etc/yum/pluginconf.d/update-motd.conf /usr/sbin/update-motd /usr/lib/yum-plugins/update-motd.py* diff --git a/srpm/upstart_update-motd.conf b/srpm/upstart_update-motd.conf deleted file mode 100644 index 7197244..0000000 --- a/srpm/upstart_update-motd.conf +++ /dev/null @@ -1,2 +0,0 @@ -start on stopped rc RUNLEVEL=[2345] -exec /usr/sbin/update-motd