Sfoglia il codice sorgente

Add Upstart job configuration file

Signed-off-by: Kazunori INOUE <inouekazu@intellilink.co.jp>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Kazunori INOUE 13 anni fa
parent
commit
ca389c3c59
5 ha cambiato i file con 124 aggiunte e 4 eliminazioni
  1. 16 0
      configure.ac
  2. 10 1
      corosync.spec.in
  3. 8 3
      init/Makefile.am
  4. 38 0
      init/corosync-notifyd.conf.in
  5. 52 0
      init/corosync.conf.in

+ 16 - 0
configure.ac

@@ -343,6 +343,11 @@ AC_ARG_ENABLE([systemd],
 	[ enable_systemd="no" ])
 AM_CONDITIONAL(INSTALL_SYSTEMD, test x$enable_systemd = xyes)
 
+AC_ARG_ENABLE([upstart],
+	      [  --enable-upstart                : Install upstart service files],,
+	[ enable_upstart="no" ])
+AM_CONDITIONAL(INSTALL_UPSTART, test x$enable_upstart = xyes)
+
 AC_ARG_WITH([initddir],
 	[  --with-initddir=DIR     : path to init script directory. ],
 	[ INITDDIR="$withval" ],
@@ -353,6 +358,11 @@ AC_ARG_WITH([systemddir],
 	[ SYSTEMDDIR="$withval" ],
 	[ SYSTEMDDIR="/lib/systemd/system" ])
 
+AC_ARG_WITH([upstartdir],
+	[  --with-upstartdir=DIR   : path to upstart config files directory. ],
+	[ UPSTARTDIR="$withval" ],
+	[ UPSTARTDIR="$sysconfdir/init" ])
+
 AC_ARG_WITH([initwrappersdir],
 	[  --with-initwrappersdir=DIR   : path to init wrappers files directory. ],
 	[ INITWRAPPERSDIR="$withval" ],
@@ -438,6 +448,10 @@ if test "x${enable_systemd}" = xyes; then
 	PACKAGE_FEATURES="$PACKAGE_FEATURES systemd"
 	WITH_LIST="$WITH_LIST --with systemd"
 fi
+if test "x${enable_upstart}" = xyes; then
+	PACKAGE_FEATURES="$PACKAGE_FEATURES upstart"
+	WITH_LIST="$WITH_LIST --with upstart"
+fi
 if test "x${enable_xmlconf}" = xyes; then
 	PACKAGE_FEATURES="$PACKAGE_FEATURES xmlconf"
 	WITH_LIST="$WITH_LIST --with xmlconf"
@@ -653,6 +667,7 @@ fi
 AC_SUBST([BASHPATH])
 AC_SUBST([INITDDIR])
 AC_SUBST([SYSTEMDDIR])
+AC_SUBST([UPSTARTDIR])
 INITWRAPPERSDIR=$(eval echo ${INITWRAPPERSDIR})
 AC_SUBST([INITWRAPPERSDIR])
 
@@ -695,6 +710,7 @@ 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 upstart directory = ${UPSTARTDIR}])
 AC_MSG_RESULT([  System init wraps dir    = ${INITWRAPPERSDIR}])
 AC_MSG_RESULT([  corosync config dir      = ${COROSYSCONFDIR}])
 AC_MSG_RESULT([  Features                 =${PACKAGE_FEATURES}])

+ 10 - 1
corosync.spec.in

@@ -12,6 +12,7 @@
 %bcond_with dbus
 %bcond_with rdma
 %bcond_with systemd
+%bcond_with upstart
 %bcond_with xmlconf
 %bcond_with runautogen
 
@@ -102,11 +103,15 @@ export rdmacm_LIBS=-lrdmacm \
 %if %{with systemd}
 	--enable-systemd \
 %endif
+%if %{with upstart}
+	--enable-upstart \
+%endif
 %if %{with xmlconf}
 	--enable-xmlconf \
 %endif
 	--with-initddir=%{_initrddir} \
-	--with-systemddir=%{_unitdir}
+	--with-systemddir=%{_unitdir} \
+	--with-upstartdir=%{_sysconfdir}/init
 
 make %{_smp_mflags}
 
@@ -197,6 +202,10 @@ fi
 %{_initrddir}/corosync
 %{_initrddir}/corosync-notifyd
 %endif
+%if %{with upstart}
+%{_sysconfdir}/init/corosync.conf
+%{_sysconfdir}/init/corosync-notifyd.conf
+%endif
 %dir %{_localstatedir}/lib/corosync
 %dir %{_localstatedir}/log/cluster
 %{_mandir}/man8/corosync_overview.8*

+ 8 - 3
init/Makefile.am

@@ -34,7 +34,7 @@
 
 MAINTAINERCLEANFILES	= Makefile.in
 
-EXTRA_DIST		= corosync.in corosync-notifyd.in corosync.service.in corosync-notifyd.service.in
+EXTRA_DIST		= corosync.in corosync-notifyd.in corosync.service.in corosync-notifyd.service.in corosync.conf.in corosync-notifyd.conf.in
 
 if INSTALL_SYSTEMD
 systemdconfdir	   = $(SYSTEMDDIR)
@@ -45,6 +45,11 @@ initscriptdir	   = $(INITDDIR)
 endif
 initscript_SCRIPTS  = corosync corosync-notifyd
 
+if INSTALL_UPSTART
+upstartconfdir     = $(UPSTARTDIR)
+upstartconf_DATA   = corosync.conf corosync-notifyd.conf
+endif
+
 %: %.in Makefile
 	rm -f $@-t $@
 	cat $< | sed \
@@ -57,7 +62,7 @@ initscript_SCRIPTS  = corosync corosync-notifyd
 	    > $@-t
 	mv $@-t $@
 
-all-local: $(initscript_SCRIPTS) $(systemdconf_DATA)
+all-local: $(initscript_SCRIPTS) $(systemdconf_DATA) $(upstartconf_DATA)
 
 clean-local:
-	rm -rf $(initscript_SCRIPTS) $(systemdconf_DATA)
+	rm -rf $(initscript_SCRIPTS) $(systemdconf_DATA) $(upstartconf_DATA)

+ 38 - 0
init/corosync-notifyd.conf.in

@@ -0,0 +1,38 @@
+# corosync-notifyd - Corosync Dbus and snmp notifier
+#
+# Starts corosync-notifyd
+
+expect fork
+respawn
+
+env prog=corosync-notifyd
+env rpm_sysconf=@SYSCONFDIR@/sysconfig/corosync-notifyd
+env rpm_lockfile=@LOCALSTATEDIR@/lock/subsys/corosync-notifyd
+env deb_sysconf=@SYSCONFDIR@/default/corosync-notifyd
+env deb_lockfile=@LOCALSTATEDIR@/lock/corosync-notifyd
+
+script
+    [ -f "$rpm_sysconf" ] && . $rpm_sysconf
+    [ -f "$deb_sysconf" ] && . $deb_sysconf
+    exec $prog $OPTIONS
+end script
+
+pre-start script
+    mkdir -p @LOCALSTATEDIR@/run
+end script
+
+post-start script
+    [ -f "$rpm_sysconf" ] && . $rpm_sysconf
+    [ -f "$deb_sysconf" ] && . $deb_sysconf
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/sysconfig ] && LOCK_FILE="$rpm_lockfile"
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/default ] && LOCK_FILE="$deb_lockfile"
+    touch $LOCK_FILE
+end script
+
+post-stop script
+    [ -f "$rpm_sysconf" ] && . $rpm_sysconf
+    [ -f "$deb_sysconf" ] && . $deb_sysconf
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/sysconfig ] && LOCK_FILE="$rpm_lockfile"
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/default ] && LOCK_FILE="$deb_lockfile"
+    rm -f $LOCK_FILE
+end script

+ 52 - 0
init/corosync.conf.in

@@ -0,0 +1,52 @@
+# corosync - Corosync Cluster Engine
+#
+# Starts corosync
+
+expect fork
+
+env prog=corosync
+env rpm_sysconf=@SYSCONFDIR@/sysconfig/corosync
+env rpm_lockfile=@LOCALSTATEDIR@/lock/subsys/corosync
+env deb_sysconf=@SYSCONFDIR@/default/corosync
+env deb_lockfile=@LOCALSTATEDIR@/lock/corosync
+
+script
+    [ -f "$rpm_sysconf" ] && . $rpm_sysconf
+    [ -f "$deb_sysconf" ] && . $deb_sysconf
+    exec $prog
+end script
+
+pre-start script
+    mkdir -p @LOCALSTATEDIR@/run
+end script
+
+post-start script
+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
+    logger -i -t "$UPSTART_JOB" "ERROR: Any interfaces are faulty!"
+    return 1
+}
+    wait_for_ipc || { stop; exit 1; }
+
+    [ -f "$rpm_sysconf" ] && . $rpm_sysconf
+    [ -f "$deb_sysconf" ] && . $deb_sysconf
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/sysconfig ] && LOCK_FILE="$rpm_lockfile"
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/default ] && LOCK_FILE="$deb_lockfile"
+    touch $LOCK_FILE
+end script
+
+post-stop script
+    [ -f "$rpm_sysconf" ] && . $rpm_sysconf
+    [ -f "$deb_sysconf" ] && . $deb_sysconf
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/sysconfig ] && LOCK_FILE="$rpm_lockfile"
+    [ -z "$LOCK_FILE" -a -d @SYSCONFDIR@/default ] && LOCK_FILE="$deb_lockfile"
+    rm -f $LOCK_FILE
+end script