From 6fa114ac8db9c1e2eaa76a9c1eaea0ce3682d79c Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Mon, 8 Aug 2011 21:01:52 +1000 Subject: [PATCH] Add systemd unit files for corosync and corosync-notifyd Signed-off-by: Angus Salkeld Reviewed-by: Steven Dake --- configure.ac | 8 ++++++++ corosync.spec.in | 12 ++++++++++++ init/.gitignore | 2 ++ init/Makefile.am | 15 +++++++++++---- init/corosync-notifyd.service.in | 11 +++++++++++ init/corosync.service.in | 12 ++++++++++++ 6 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 init/corosync-notifyd.service.in create mode 100644 init/corosync.service.in diff --git a/configure.ac b/configure.ac index 7a5ab62b..ca5485bc 100644 --- a/configure.ac +++ b/configure.ac @@ -272,6 +272,11 @@ AC_ARG_ENABLE([augeas], [ enable_augeas="no" ]) 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], [ --with-initddir=DIR : path to init script directory. ], [ INITDDIR="$withval" ], @@ -441,6 +446,9 @@ fi if test "x${enable_augeas}" = xyes; then PACKAGE_FEATURES="$PACKAGE_FEATURES augeas" fi +if test "x${enable_systemd}" = xyes; then + PACKAGE_FEATURES="$PACKAGE_FEATURES systemd" +fi if test "x${enable_snmp}" = xyes; then SNMPCONFIG="" diff --git a/corosync.spec.in b/corosync.spec.in index b11a9444..c4819e00 100644 --- a/corosync.spec.in +++ b/corosync.spec.in @@ -11,6 +11,7 @@ %bcond_with snmp %bcond_with dbus %bcond_with rdma +%bcond_with systemd Name: corosync Summary: The Corosync Cluster Engine and Application Programming Interfaces @@ -46,6 +47,9 @@ BuildRequires: net-snmp-devel %if %{with dbus} BuildRequires: dbus-devel %endif +%if %{with systemd} +BuildRequires: systemd-units +%endif BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) @@ -82,6 +86,9 @@ export rdmacm_LIBS=-lrdmacm \ %endif %if %{with rdma} --enable-rdma \ +%endif +%if %{with systemd} + --enable-systemd \ %endif --with-initddir=%{_initrddir} @@ -146,8 +153,13 @@ fi %if %{with snmp} %{_datadir}/snmp/mibs/COROSYNC-MIB.txt %endif +%if %{with systemd} +%{_unitdir}/corosync.service +%{_unitdir}/corosync-notifyd.service +%else %{_initrddir}/corosync %{_initrddir}/corosync-notifyd +%endif %dir %{_libexecdir}/lcrso %{_libexecdir}/lcrso/coroparse.lcrso %{_libexecdir}/lcrso/objdb.lcrso diff --git a/init/.gitignore b/init/.gitignore index 0a75c320..34e4cb8c 100644 --- a/init/.gitignore +++ b/init/.gitignore @@ -1,2 +1,4 @@ generic notifyd +corosync.service +corosync-notifyd.service diff --git a/init/Makefile.am b/init/Makefile.am index 0ca9ee97..90d49c4d 100644 --- a/init/Makefile.am +++ b/init/Makefile.am @@ -34,9 +34,14 @@ 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 +endif %: %.in Makefile rm -f $@-t $@ @@ -46,14 +51,15 @@ target_INIT = generic notifyd -e 's#@''INITDDIR@#$(INITDDIR)#g' \ -e 's#@''LOCALSTATEDIR@#$(localstatedir)#g' \ $< > $@-t - chmod 0755 $@-t mv $@-t $@ -all-local: $(target_INIT) +all-local: $(target_INIT) $(systemdconf_DATA) clean-local: - rm -rf $(target_INIT) + rm -rf $(target_INIT) $(systemdconf_DATA) +if INSTALL_SYSTEMD +else install-exec-local: $(INSTALL) -d $(DESTDIR)/$(INITDDIR) $(INSTALL) -m 755 generic $(DESTDIR)/$(INITDDIR)/corosync @@ -62,3 +68,4 @@ install-exec-local: uninstall-local: cd $(DESTDIR)/$(INITDDIR) && \ rm -f corosync corosync-notifyd +endif diff --git a/init/corosync-notifyd.service.in b/init/corosync-notifyd.service.in new file mode 100644 index 00000000..26a278a2 --- /dev/null +++ b/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 diff --git a/init/corosync.service.in b/init/corosync.service.in new file mode 100644 index 00000000..8cc692be --- /dev/null +++ b/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