@@ -177,6 +177,10 @@ install-data-hook:
if ENABLE_RDMA_NDD
install-exec-hook:
+if SYSTEMD_SYSTEM_UNIT_DIR
+ $(top_srcdir)/config/install-sh -m 755 $(top_srcdir)/etc/rdma-ndd.service $(DESTDIR)/$(prefix)/$(SYSTEMD_SYSTEM_UNIT_DIR)/rdma-ndd.service
+else
$(top_srcdir)/config/install-sh -m 755 -d $(DESTDIR)/$(sysconfdir)/init.d
$(top_srcdir)/config/install-sh -m 755 $(top_srcdir)/etc/rdma-ndd.init $(DESTDIR)/$(sysconfdir)/init.d/rdma-ndd
endif
+endif
@@ -180,6 +180,28 @@ fi
AC_SUBST(ibnetdisc_api_version)
dnl End libibnetdisc stuff
+dnl Begin determine the systemd use and location
+use_systemd=`cat /proc/1/comm`
+with_sysemdsystemunitdir="no"
+specfile_install="%{_sysconfdir}/init.d/rdma-ndd"
+if test "x$use_systemd" == xsystemd; then
+ def_systemdsystemunitdir="lib/systemd/system"
+ AC_ARG_WITH([systemdsystemunitdir],
+ AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
+ [Directory for systemd service files]),
+ [with_systemdsystemunitdir=$withval],
+ [with_sysemdsystemunitdir=$def_systemdsystemunitdir])
+ if test "x$with_sysemdsystemunitdir" != xno; then
+ AC_SUBST(SYSTEMD_SYSTEM_UNIT_DIR, [$with_sysemdsystemunitdir])
+ AC_SUBST(SYSTEMD_BUILD_REQUIRES, "BuildRequires: systemd")
+ specfile_install="%{_prefix}/lib/systemd/system/rdma-ndd.service"
+ fi
+fi
+AM_CONDITIONAL(SYSTEMD_SYSTEM_UNIT_DIR, test "x$with_sysemdsystemunitdir" != xno)
+AC_SUBST(SPEC_FILE_RDMA_NDD_INSTALL, $specfile_install)
+dnl End systemd stuff
+
+
dnl with or with rdma-ndd
AC_MSG_CHECKING(for --enable-rdma-ndd)
AC_ARG_ENABLE(rdma-ndd,
@@ -212,7 +234,9 @@ AC_SUBST(DEFAULT_STOP, $default_stop)
AS_IF([test x$rdmandd = xyes], [
PKG_CHECK_MODULES([UDEV], [libudev])
- AC_CONFIG_FILES([doc/man/rdma-ndd.8 etc/rdma-ndd.init])
+ AC_CONFIG_FILES([doc/man/rdma-ndd.8 \
+ etc/rdma-ndd.init \
+ etc/rdma-ndd.service])
AC_SUBST([UDEV_CFLAGS])
AC_SUBST([UDEV_LIBS])
if test "$with_udev" = "yes"; then
new file mode 100644
@@ -0,0 +1,12 @@
+[Unit]
+Description=RDMA Node Description Daemon
+After=rdma.service
+
+[Service]
+Type=forking
+EnvironmentFile=@IBDIAG_CONFIG_PATH@/ibdiag.conf
+ExecStart=@exec_prefix@/sbin/rdma-ndd
+
+[Install]
+WantedBy=multi-user.target
+
@@ -12,6 +12,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Source: http://www.openfabrics.org/downloads/management/@TARBALL@
Url: http://openfabrics.org/
BuildRequires: libibmad-devel, opensm-devel, libibumad-devel, glib2-devel, libudev-devel
+@SYSTEMD_BUILD_REQUIRES@
Requires: libibmad, opensm-libs, libibumad, glib2
Provides: perl(IBswcountlimits)
Obsoletes: openib-diags
@@ -167,36 +168,35 @@ rm -rf $RPM_BUILD_ROOT
%define _perldir %(perl -e 'use Config; $T=$Config{installvendorlib}; print $T;')
%{_perldir}/*
%{_sysconfdir}/infiniband-diags/*
-%{_sysconfdir}/init.d/rdma-ndd
+@SPEC_FILE_RDMA_NDD_INSTALL@
%doc README COPYING ChangeLog
%post
if [ $1 = 1 ]; then
- if [ -e /sbin/chkconfig ]; then
+ if [ -e /etc/init.d/rdma-ndd ] && [ -e /sbin/chkconfig ]; then
/sbin/chkconfig --add rdma-ndd
- /sbin/chkconfig rdma-ndd on
- elif [ -e /usr/sbin/update-rc.d ]; then
- /usr/sbin/update-rc.d rdma-ndd defaults
- else
- /usr/lib/lsb/install_initd /etc/init.d/rdma-ndd
fi
if type systemctl >/dev/null 2>&1; then
- systemctl --system daemon-reload
+ systemctl daemon-reload
fi
-else
- /etc/init.d/rdma-ndd condrestart
fi
%preun
if [ $1 = 0 ]; then
- /etc/init.d/rdma-ndd stop
- if [ -e /sbin/chkconfig ]; then
+ if [ -e /etc/init.d/rdma-ndd ] && [ -e /sbin/chkconfig ]; then
+ /etc/init.d/rdma-ndd stop
/sbin/chkconfig --del rdma-ndd
- elif [ -e /usr/sbin/update-rc.d ]; then
- /usr/sbin/update-rc.d -f rdma-ndd remove
- else
- /usr/lib/lsb/remove_initd /etc/init.d/rdma-ndd
+ fi
+ if type systemctl >/dev/null 2>&1; then
+ systemctl stop rdma-ndd
+ fi
+fi
+
+%postun
+if [ $1 = 0 ]; then
+ if type systemctl >/dev/null 2>&1; then
+ systemctl daemon-reload
fi
fi