Skip to content

Commit

Permalink
Add systemd unit file for kojira
Browse files Browse the repository at this point in the history
Signed-off-by: Dennis Gilmore <[email protected]>
  • Loading branch information
ausil committed Jun 7, 2015
1 parent 7c43549 commit 9c69602
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
22 changes: 22 additions & 0 deletions koji.spec
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ Group: Applications/Internet
License: LGPLv2
Requires: postgresql-python
Requires: %{name} = %{version}-%{release}
%if %{use_systemd}
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%endif

%description utils
Utilities for the Koji system
Expand Down Expand Up @@ -191,8 +196,12 @@ rm -rf $RPM_BUILD_ROOT
%files utils
%defattr(-,root,root)
%{_sbindir}/kojira
%if %{use_systemd}
%{_unitdir}/kojira.service
%else
%{_initrddir}/kojira
%config(noreplace) %{_sysconfdir}/sysconfig/kojira
%endif
%dir %{_sysconfdir}/kojira
%config(noreplace) %{_sysconfdir}/kojira/kojira.conf
%{_sbindir}/koji-gc
Expand Down Expand Up @@ -288,6 +297,18 @@ if [ $1 = 0 ]; then
fi
%endif

%if %{use_systemd}

%post utils
%systemd_post kojira.service

%preun utils
%systemd_preun kojira.service

%postun utils
%systemd_postun kojira.service

%else
%post utils
/sbin/chkconfig --add kojira
/sbin/service kojira condrestart &> /dev/null || :
Expand All @@ -296,6 +317,7 @@ if [ $1 = 0 ]; then
/sbin/service kojira stop &> /dev/null || :
/sbin/chkconfig --del kojira
fi
%endif

%changelog
* Mon Mar 24 2014 Mike McLean <mikem at redhat.com> - 1.9.0-1
Expand Down
23 changes: 16 additions & 7 deletions util/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
BINFILES = kojira koji-gc koji-shadow
SYSTEMDSYSTEMUNITDIR = $(shell pkg-config systemd --variable=systemdsystemunitdir)
TYPE = systemd

_default:
@echo "nothing to make. try make install"

clean:
rm -f *.o *.so *.pyc *~

install:
_install:
@if [ "$(DESTDIR)" = "" ]; then \
echo " "; \
echo "ERROR: A destdir is required"; \
Expand All @@ -15,12 +17,6 @@ install:
mkdir -p $(DESTDIR)/usr/sbin
install -p -m 755 $(BINFILES) $(DESTDIR)/usr/sbin

mkdir -p $(DESTDIR)/etc/rc.d/init.d
install -p -m 755 kojira.init $(DESTDIR)/etc/rc.d/init.d/kojira

mkdir -p $(DESTDIR)/etc/sysconfig
install -p -m 644 kojira.sysconfig $(DESTDIR)/etc/sysconfig/kojira

mkdir -p $(DESTDIR)/etc/kojira
install -p -m 644 kojira.conf $(DESTDIR)/etc/kojira/kojira.conf

Expand All @@ -29,3 +25,16 @@ install:

mkdir -p $(DESTDIR)/etc/koji-shadow
install -p -m 644 koji-shadow.conf $(DESTDIR)/etc/koji-shadow/koji-shadow.conf

install-systemd: _install
mkdir -p $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)
install -p -m 644 kojira.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)

install-sysv: _install
mkdir -p $(DESTDIR)/etc/rc.d/init.d
install -p -m 755 kojira.init $(DESTDIR)/etc/rc.d/init.d/kojira

mkdir -p $(DESTDIR)/etc/sysconfig
install -p -m 644 kojira.sysconfig $(DESTDIR)/etc/sysconfig/kojira

install: install-$(TYPE)
14 changes: 14 additions & 0 deletions util/kojira.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Koji repo administration
Documentation=https://fedoraproject.org/wiki/Koji/ServerHowTo

After=network.target

[Service]
ExecStart=/usr/sbin/kojira \
--fg \
--force-lock \
--verbose

[Install]
WantedBy=multi-user.target

0 comments on commit 9c69602

Please sign in to comment.