4
0
Эх сурвалжийг харах

Add systemd unit files for corosync and corosync-notifyd

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
Angus Salkeld 14 жил өмнө
parent
commit
6fa114ac8d

+ 8 - 0
configure.ac

@@ -272,6 +272,11 @@ AC_ARG_ENABLE([augeas],
 	[ enable_augeas="no" ])
 	[ enable_augeas="no" ])
 AM_CONDITIONAL(INSTALL_AUGEAS, test x$enable_augeas = xyes)
 AM_CONDITIONAL(INSTALL_AUGEAS, test x$enable_augeas = xyes)
 
 
+AC_ARG_ENABLE([systemd],
+	      [  --enable-systemd               : Install systemd service files],,
+	[ enable_systemd="no" ])
+AM_CONDITIONAL(INSTALL_SYSTEMD, test x$enable_systemd = xyes)
+
 AC_ARG_WITH([initddir],
 AC_ARG_WITH([initddir],
 	[  --with-initddir=DIR     : path to init script directory. ],
 	[  --with-initddir=DIR     : path to init script directory. ],
 	[ INITDDIR="$withval" ],
 	[ INITDDIR="$withval" ],
@@ -441,6 +446,9 @@ fi
 if test "x${enable_augeas}" = xyes; then
 if test "x${enable_augeas}" = xyes; then
 	PACKAGE_FEATURES="$PACKAGE_FEATURES augeas"
 	PACKAGE_FEATURES="$PACKAGE_FEATURES augeas"
 fi
 fi
+if test "x${enable_systemd}" = xyes; then
+	PACKAGE_FEATURES="$PACKAGE_FEATURES systemd"
+fi
 
 
 if test "x${enable_snmp}" = xyes; then
 if test "x${enable_snmp}" = xyes; then
        SNMPCONFIG=""
        SNMPCONFIG=""

+ 12 - 0
corosync.spec.in

@@ -11,6 +11,7 @@
 %bcond_with snmp
 %bcond_with snmp
 %bcond_with dbus
 %bcond_with dbus
 %bcond_with rdma
 %bcond_with rdma
+%bcond_with systemd
 
 
 Name: corosync
 Name: corosync
 Summary: The Corosync Cluster Engine and Application Programming Interfaces
 Summary: The Corosync Cluster Engine and Application Programming Interfaces
@@ -46,6 +47,9 @@ BuildRequires: net-snmp-devel
 %if %{with dbus}
 %if %{with dbus}
 BuildRequires: dbus-devel
 BuildRequires: dbus-devel
 %endif
 %endif
+%if %{with systemd}
+BuildRequires: systemd-units
+%endif
 
 
 BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 
 
@@ -82,6 +86,9 @@ export rdmacm_LIBS=-lrdmacm \
 %endif
 %endif
 %if %{with rdma}
 %if %{with rdma}
 	--enable-rdma \
 	--enable-rdma \
+%endif
+%if %{with systemd}
+	--enable-systemd \
 %endif
 %endif
 	--with-initddir=%{_initrddir}
 	--with-initddir=%{_initrddir}
 
 
@@ -146,8 +153,13 @@ fi
 %if %{with snmp}
 %if %{with snmp}
 %{_datadir}/snmp/mibs/COROSYNC-MIB.txt
 %{_datadir}/snmp/mibs/COROSYNC-MIB.txt
 %endif
 %endif
+%if %{with systemd}
+%{_unitdir}/corosync.service
+%{_unitdir}/corosync-notifyd.service
+%else
 %{_initrddir}/corosync
 %{_initrddir}/corosync
 %{_initrddir}/corosync-notifyd
 %{_initrddir}/corosync-notifyd
+%endif
 %dir %{_libexecdir}/lcrso
 %dir %{_libexecdir}/lcrso
 %{_libexecdir}/lcrso/coroparse.lcrso
 %{_libexecdir}/lcrso/coroparse.lcrso
 %{_libexecdir}/lcrso/objdb.lcrso
 %{_libexecdir}/lcrso/objdb.lcrso

+ 2 - 0
init/.gitignore

@@ -1,2 +1,4 @@
 generic
 generic
 notifyd
 notifyd
+corosync.service
+corosync-notifyd.service

+ 11 - 4
init/Makefile.am

@@ -34,9 +34,14 @@
 
 
 MAINTAINERCLEANFILES	= Makefile.in
 MAINTAINERCLEANFILES	= Makefile.in
 
 
-EXTRA_DIST		= generic.in notifyd.in
+EXTRA_DIST		= generic.in notifyd.in corosync.service.in corosync-notifyd.service.in
 
 
+if INSTALL_SYSTEMD
+systemdconfdir = /lib/systemd/system
+systemdconf_DATA = corosync.service corosync-notifyd.service
+else
 target_INIT		= generic notifyd
 target_INIT		= generic notifyd
+endif
 
 
 %: %.in Makefile
 %: %.in Makefile
 	rm -f $@-t $@
 	rm -f $@-t $@
@@ -46,14 +51,15 @@ target_INIT		= generic notifyd
 		-e 's#@''INITDDIR@#$(INITDDIR)#g' \
 		-e 's#@''INITDDIR@#$(INITDDIR)#g' \
 		-e 's#@''LOCALSTATEDIR@#$(localstatedir)#g' \
 		-e 's#@''LOCALSTATEDIR@#$(localstatedir)#g' \
 	    $< > $@-t
 	    $< > $@-t
-	chmod 0755 $@-t
 	mv $@-t $@
 	mv $@-t $@
 
 
-all-local: $(target_INIT)
+all-local: $(target_INIT) $(systemdconf_DATA)
 
 
 clean-local:
 clean-local:
-	rm -rf $(target_INIT)
+	rm -rf $(target_INIT) $(systemdconf_DATA)
 
 
+if INSTALL_SYSTEMD
+else
 install-exec-local:
 install-exec-local:
 	$(INSTALL) -d $(DESTDIR)/$(INITDDIR)
 	$(INSTALL) -d $(DESTDIR)/$(INITDDIR)
 	$(INSTALL) -m 755 generic $(DESTDIR)/$(INITDDIR)/corosync
 	$(INSTALL) -m 755 generic $(DESTDIR)/$(INITDDIR)/corosync
@@ -62,3 +68,4 @@ install-exec-local:
 uninstall-local:
 uninstall-local:
 	cd $(DESTDIR)/$(INITDDIR) && \
 	cd $(DESTDIR)/$(INITDDIR) && \
 		rm -f corosync corosync-notifyd
 		rm -f corosync corosync-notifyd
+endif

+ 11 - 0
init/corosync-notifyd.service.in

@@ -0,0 +1,11 @@
+[Unit]
+Description=Corosync Dbus and snmp notifier
+Wants=corosync.service
+
+[Service]
+EnvironmentFile=@SYSCONFIGDIR@/corosync-notifyd
+ExecStart=@SBINDIR@/corosync-notifyd -f $OPTIONS
+Type=simple
+
+[Install]
+WantedBy=multi-user.target

+ 12 - 0
init/corosync.service.in

@@ -0,0 +1,12 @@
+[Unit]
+Description=Corosync Cluster Engine
+ConditionKernelCommandLine=!nocluster
+#Conflicts=cman.service
+
+[Service]
+ExecStart=@SBINDIR@/corosync
+Type=forking
+#RestartSec=90s
+
+[Install]
+WantedBy=multi-user.target