diff --git a/TODO b/TODO index 18a8a086..c831948a 100644 --- a/TODO +++ b/TODO @@ -17,7 +17,6 @@ * porting of qdisk to votequorum and eventually finalize qdevice API in votequorum. (Fabio) * Cleaner shutdown process -> free memory (Fabio) -* Merge init and systemd stuff (Fabio) -------------------------------------- Current priority list for Needle 2.X diff --git a/configure.ac b/configure.ac index f2222b2c..7ce168f0 100644 --- a/configure.ac +++ b/configure.ac @@ -290,6 +290,11 @@ AC_ARG_WITH([systemddir], [ SYSTEMDDIR="$withval" ], [ SYSTEMDDIR="/lib/systemd/system" ]) +AC_ARG_WITH([initwrappersdir], + [ --with-initwrappersdir=DIR : path to init wrappers files directory. ], + [ INITWRAPPERSDIR="$withval" ], + [ INITWRAPPERSDIR="$datarootdir/corosync" ]) + AC_ARG_ENABLE([snmp], [ --enable-snmp : SNMP protocol support ], [ default="no" ]) @@ -585,6 +590,8 @@ LDFLAGS="$ENV_LDFLAGS $COVERAGE_LDFLAGS $OS_LDFLAGS" # substitute what we need: AC_SUBST([INITDDIR]) AC_SUBST([SYSTEMDDIR]) +INITWRAPPERSDIR=$(eval echo ${INITWRAPPERSDIR}) +AC_SUBST([INITWRAPPERSDIR]) AC_SUBST([SOMAJOR]) AC_SUBST([SOMINOR]) @@ -631,6 +638,8 @@ AC_MSG_RESULT([ Arch-independent files = ${datadir}]) AC_MSG_RESULT([ State information = ${localstatedir}]) AC_MSG_RESULT([ System configuration = ${sysconfdir}]) AC_MSG_RESULT([ System init.d directory = ${INITDDIR}]) +AC_MSG_RESULT([ System systemd directory = ${SYSTEMDDIR}]) +AC_MSG_RESULT([ System init wraps dir = ${INITWRAPPERSDIR}]) AC_MSG_RESULT([ corosync config dir = ${COROSYSCONFDIR}]) AC_MSG_RESULT([ Features =${PACKAGE_FEATURES}]) AC_MSG_RESULT([]) diff --git a/corosync.spec.in b/corosync.spec.in index 40623512..1c99d20a 100644 --- a/corosync.spec.in +++ b/corosync.spec.in @@ -169,6 +169,9 @@ fi %if %{with systemd} %{_unitdir}/corosync.service %{_unitdir}/corosync-notifyd.service +%dir %{_datadir}/corosync +%{_datadir}/corosync/corosync +%{_datadir}/corosync/corosync-notifyd %else %{_initrddir}/corosync %{_initrddir}/corosync-notifyd diff --git a/init/Makefile.am b/init/Makefile.am index 00d56d41..8e4d4c7c 100644 --- a/init/Makefile.am +++ b/init/Makefile.am @@ -34,38 +34,30 @@ MAINTAINERCLEANFILES = Makefile.in -EXTRA_DIST = generic.in notifyd.in corosync.service.in corosync-notifyd.service.in +EXTRA_DIST = corosync.in corosync-notifyd.in corosync.service.in corosync-notifyd.service.in if INSTALL_SYSTEMD -systemdconfdir = $(SYSTEMDDIR) -systemdconf_DATA = corosync.service corosync-notifyd.service +systemdconfdir = $(SYSTEMDDIR) +systemdconf_DATA = corosync.service corosync-notifyd.service +initscriptdir = $(INITWRAPPERSDIR) else -target_INIT = generic notifyd +initscriptdir = $(INITDDIR) endif +initscript_SCRIPTS = corosync corosync-notifyd %: %.in Makefile rm -f $@-t $@ - sed \ + cp $< $@-t + sed -i \ -e 's#@''SBINDIR@#$(sbindir)#g' \ -e 's#@''SYSCONFDIR@#$(sysconfdir)#g' \ -e 's#@''INITDDIR@#$(INITDDIR)#g' \ + -e 's#@''INITWRAPPERSDIR@#$(INITWRAPPERSDIR)#g' \ -e 's#@''LOCALSTATEDIR@#$(localstatedir)#g' \ - $< > $@-t + $@-t mv $@-t $@ -all-local: $(target_INIT) $(systemdconf_DATA) +all-local: $(initscript_SCRIPTS) $(systemdconf_DATA) clean-local: - rm -rf $(target_INIT) $(systemdconf_DATA) - -if INSTALL_SYSTEMD -else -install-exec-local: - $(INSTALL) -d $(DESTDIR)/$(INITDDIR) - $(INSTALL) -m 755 generic $(DESTDIR)/$(INITDDIR)/corosync - $(INSTALL) -m 755 notifyd $(DESTDIR)/$(INITDDIR)/corosync-notifyd - -uninstall-local: - cd $(DESTDIR)/$(INITDDIR) && \ - rm -f corosync corosync-notifyd -endif + rm -rf $(initscript_SCRIPTS) $(systemdconf_DATA) diff --git a/init/notifyd.in b/init/corosync-notifyd.in similarity index 100% rename from init/notifyd.in rename to init/corosync-notifyd.in diff --git a/init/corosync-notifyd.service.in b/init/corosync-notifyd.service.in index 26a278a2..172653cf 100644 --- a/init/corosync-notifyd.service.in +++ b/init/corosync-notifyd.service.in @@ -1,6 +1,7 @@ [Unit] Description=Corosync Dbus and snmp notifier Wants=corosync.service +After=corosync.service [Service] EnvironmentFile=@SYSCONFIGDIR@/corosync-notifyd diff --git a/init/generic.in b/init/corosync.in similarity index 88% rename from init/generic.in rename to init/corosync.in index 1ce26f0d..a9840bd9 100755 --- a/init/generic.in +++ b/init/corosync.in @@ -81,6 +81,20 @@ cluster_disabled_at_boot() return 0 } +wait_for_ipc() +{ + try=0 + while [ "$try" -le "20" ]; do + if corosync-cfgtool -s > /dev/null 2>&1; then + return 0 + fi + sleep 0.5 + try=$((try + 1)) + done + + return 1 +} + start() { echo -n "Starting $desc ($prog): " @@ -98,40 +112,20 @@ start() else $prog > /dev/null 2>&1 - # give it time to fail - sleep 2 - if status $prog > /dev/null 2>&1; then - touch $LOCK_FILE - success - else + if ! wait_for_ipc; then failure rtrn=1 fi + touch $LOCK_FILE + success fi echo } -executed_by_cman() -{ - [ -f @LOCALSTATEDIR@/run/cman.pid ] || return 0 - - read cman_pid foo < @LOCALSTATEDIR@/run/cman.pid - if [ "$(pidof $prog)" == "$cman_pid" ];then - echo -n "$desc was executed by cman" - failure - echo - return 1 - fi - - return 0 -} - stop() { ! status $prog > /dev/null 2>&1 && return - ! executed_by_cman && return - echo -n "Signaling $desc ($prog) to terminate: " kill -TERM $(pidof $prog) > /dev/null 2>&1 success diff --git a/init/corosync.service.in b/init/corosync.service.in index 8cc692be..8a43ccf1 100644 --- a/init/corosync.service.in +++ b/init/corosync.service.in @@ -1,12 +1,13 @@ [Unit] Description=Corosync Cluster Engine ConditionKernelCommandLine=!nocluster -#Conflicts=cman.service +Requires=network.target +After=network.target [Service] -ExecStart=@SBINDIR@/corosync +ExecStart=@INITWRAPPERSDIR@/corosync start +ExecStop=@INITWRAPPERSDIR@/corosync stop Type=forking -#RestartSec=90s [Install] WantedBy=multi-user.target