Thomas's change revisited as a change to specfile:
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Mon, 30 Jun 2014 14:20:26 +0000 (16:20 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Mon, 30 Jun 2014 14:20:26 +0000 (16:20 +0200)
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

bin/lxc-sliceimage [moved from initscripts/lxc-sliceimage with 100% similarity]
cron.d/lxc-sliceimage
lxc-sliceimage.spec
systemd/lxc-sliceimage.service [new file with mode: 0644]

index a47096f..1af9e62 100644 (file)
@@ -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
index f5537b3..0001d72 100644 (file)
@@ -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 (file)
index 0000000..c3c4d67
--- /dev/null
@@ -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