From 2a061d4cdf91279d1a72c1c07cad94da519b744e Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 30 Jun 2014 16:20:26 +0200 Subject: [PATCH] Thomas's change revisited as a change to specfile: lxc-sliceimage - formerly an initscript - becomes a regular script in /usr/bin a new systemd service unit file comes as a replacement to the former initscript cron script adapted --- {initscripts => bin}/lxc-sliceimage | 0 cron.d/lxc-sliceimage | 2 +- lxc-sliceimage.spec | 20 ++++++++++++++++---- systemd/lxc-sliceimage.service | 12 ++++++++++++ 4 files changed, 29 insertions(+), 5 deletions(-) rename {initscripts => bin}/lxc-sliceimage (100%) create mode 100644 systemd/lxc-sliceimage.service diff --git a/initscripts/lxc-sliceimage b/bin/lxc-sliceimage similarity index 100% rename from initscripts/lxc-sliceimage rename to bin/lxc-sliceimage diff --git a/cron.d/lxc-sliceimage b/cron.d/lxc-sliceimage index a47096f..1af9e62 100644 --- a/cron.d/lxc-sliceimage +++ b/cron.d/lxc-sliceimage @@ -6,4 +6,4 @@ # Copyright (C) 2006 The Trustees of Princeton University # -@M@ @H@ * * * root /etc/init.d/lxc-sliceimage start >/dev/null 2>&1 +@M@ @H@ * * * root /usr/bin/lxc-sliceimage start >/dev/null 2>&1 diff --git a/lxc-sliceimage.spec b/lxc-sliceimage.spec index f5537b3..0001d72 100644 --- a/lxc-sliceimage.spec +++ b/lxc-sliceimage.spec @@ -19,6 +19,7 @@ Group: Applications/System BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot Requires: btrfs-progs Requires: nodemanager-lxc >= 5.2-3 +Requires: systemd BuildArch: noarch %description @@ -31,7 +32,8 @@ A simple package to deploy reference images for lxc %install rm -rf $RPM_BUILD_ROOT -install -D -m 755 initscripts/lxc-sliceimage ${RPM_BUILD_ROOT}/%{_initrddir}/lxc-sliceimage +install -D -m 755 bin/lxc-sliceimage ${RPM_BUILD_ROOT}/%{_bindir}/lxc-sliceimage +install -D -m 644 systemd/lxc-sliceimage.service ${RPM_BUILD_ROOT}/usr/lib/systemd/system/lxc-sliceimage.service install -D -m 644 cron.d/lxc-sliceimage $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/lxc-sliceimage install -D -m 644 logrotate/lxc-sliceimage $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/lxc-sliceimage install -D -m 644 lxc_template.xml $RPM_BUILD_ROOT/vservers/.lvref/lxc_template.xml @@ -40,14 +42,24 @@ install -D -m 644 lxc_template.xml $RPM_BUILD_ROOT/vservers/.lvref/lxc_template. rm -rf $RPM_BUILD_ROOT %files -%{_initrddir}/lxc-sliceimage +%{_bindir}/lxc-sliceimage +/lib/systemd/system/lxc-sliceimage.service %{_sysconfdir}/cron.d/lxc-sliceimage %{_sysconfdir}/logrotate.d/lxc-sliceimage /vservers/.lvref %post -chkconfig --add lxc-sliceimage -chkconfig lxc-sliceimage on +systemctl enable lxc-sliceimage.service +if [ "$PL_BOOTCD" != "1" ] ; then + systemctl restart lxc-sliceimage.service +fi + +%preun +# 0 = erase, 1 = upgrade +if [ $1 -eq 0 ] ; then + systemctl disable lxc-sliceimage.service +fi + # Randomize daily run time M=$((60 * $RANDOM / 32768)) H=$((24 * $RANDOM / 32768)) diff --git a/systemd/lxc-sliceimage.service b/systemd/lxc-sliceimage.service new file mode 100644 index 0000000..c3c4d67 --- /dev/null +++ b/systemd/lxc-sliceimage.service @@ -0,0 +1,12 @@ +[Unit] +Description=LXC Sliceimage service +Before=nm.service + +[Service] +Type=oneshot +ExecStart=/usr/bin/lxc-sliceimage start +ExecStop=/usr/bin/lxc-sliceimage stop +ExecReload=/usr/bin/lxc-sliceimage reload + +[Install] +WantedBy=multi-user.target -- 2.43.0