[PATCH 3/4] Add systemd unit file for kojivmd
Dennis Gilmore
dennis at ausil.us
Sat Jun 6 20:05:18 UTC 2015
From: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Signed-off-by: Dennis Gilmore <dennis at ausil.us>
---
koji.spec | 24 ++++++++++++++++++++++++
vm/Makefile | 18 ++++++++++++------
vm/kojivmd.service | 14 ++++++++++++++
3 files changed, 50 insertions(+), 6 deletions(-)
create mode 100644 vm/kojivmd.service
diff --git a/koji.spec b/koji.spec
index 82df76e..fbe04b7 100644
--- a/koji.spec
+++ b/koji.spec
@@ -107,10 +107,16 @@ Summary: Koji virtual machine management daemon
Group: Applications/System
License: LGPLv2
Requires: %{name} = %{version}-%{release}
+%if %{use_systemd}
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+%else
Requires(post): /sbin/chkconfig
Requires(post): /sbin/service
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
+%endif
Requires: libvirt-python
Requires: libxml2-python
Requires: /usr/bin/virt-clone
@@ -250,11 +256,28 @@ fi
%{_sbindir}/kojivmd
#dir %{_datadir}/kojivmd
%{_datadir}/kojivmd/kojikamid
+%if %{use_systemd}
+%{_unitdir}/kojivmd.service
+%else
%{_initrddir}/kojivmd
%config(noreplace) %{_sysconfdir}/sysconfig/kojivmd
+%endif
%dir %{_sysconfdir}/kojivmd
%config(noreplace) %{_sysconfdir}/kojivmd/kojivmd.conf
+%if %{use_systemd}
+
+%post vm
+%systemd_post kojivmd.service
+
+%preun vm
+%systemd_preun kojivmd.service
+
+%postun vm
+%systemd_postun kojivmd.service
+
+%else
+
%post vm
/sbin/chkconfig --add kojivmd
@@ -263,6 +286,7 @@ if [ $1 = 0 ]; then
/sbin/service kojivmd stop &> /dev/null
/sbin/chkconfig --del kojivmd
fi
+%endif
%post utils
/sbin/chkconfig --add kojira
diff --git a/vm/Makefile b/vm/Makefile
index 1dcab17..13e340c 100644
--- a/vm/Makefile
+++ b/vm/Makefile
@@ -1,6 +1,7 @@
-
BINFILES = kojivmd
SHAREFILES = kojikamid
+SYSTEMDSYSTEMUNITDIR = $(shell pkg-config systemd --variable=systemdsystemunitdir)
+TYPE = systemd
_default:
@echo "nothing to make. try make install"
@@ -11,7 +12,7 @@ clean:
kojikamid: kojikamid.py
bash fix_kojikamid.sh >kojikamid
-install: kojikamid
+_install: kojikamid
@if [ "$(DESTDIR)" = "" ]; then \
echo " "; \
echo "ERROR: A destdir is required"; \
@@ -24,13 +25,18 @@ install: kojikamid
mkdir -p $(DESTDIR)/usr/share/kojivmd
install -p -m 644 $(SHAREFILES) $(DESTDIR)/usr/share/kojivmd
+ mkdir -p $(DESTDIR)/etc/kojivmd
+ install -p -m 644 kojivmd.conf $(DESTDIR)/etc/kojivmd/kojivmd.conf
+
+install-systemd: _install
+ mkdir -p $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)
+ install -p -m 644 kojivmd.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)
+
+install-sysv: _install
mkdir -p $(DESTDIR)/etc/rc.d/init.d
install -p -m 755 kojivmd.init $(DESTDIR)/etc/rc.d/init.d/kojivmd
mkdir -p $(DESTDIR)/etc/sysconfig
install -p -m 644 kojivmd.sysconfig $(DESTDIR)/etc/sysconfig/kojivmd
- mkdir -p $(DESTDIR)/etc/kojivmd
- install -p -m 644 kojivmd.conf $(DESTDIR)/etc/kojivmd/kojivmd.conf
-
-
+install: install-$(TYPE)
diff --git a/vm/kojivmd.service b/vm/kojivmd.service
new file mode 100644
index 0000000..a417fdb
--- /dev/null
+++ b/vm/kojivmd.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Koji vm build server
+Documentation=https://fedoraproject.org/wiki/Koji/ServerHowTo
+
+After=network.target
+
+[Service]
+ExecStart=/usr/sbin/kojivmd \
+ --fg \
+ --force-lock \
+ --verbose
+
+[Install]
+WantedBy=multi-user.target
--
2.4.2
More information about the koji-devel
mailing list