Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Sep 2009 13:34:11 GMT
From:      Justin Head <ports@encarnate.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/139132: [maintainer-update] FreeBSDize Heartbeat Startup Script
Message-ID:  <200909251334.n8PDYBQG085939@www.freebsd.org>
Resent-Message-ID: <200909251340.n8PDe1HZ033871@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         139132
>Category:       ports
>Synopsis:       [maintainer-update] FreeBSDize Heartbeat Startup Script
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 25 13:40:01 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Justin Head
>Release:        7.2-RELEASE-p3
>Organization:
Encarnate
>Environment:
FreeBSD xxx.encarnate.net 7.2-RELEASE-p3 FreeBSD 7.2-RELEASE-p3 #0: Mon Sep  7 15:59:04 CDT 2009     root@xxx.encarnate.net:/usr/obj/usr/src/sys/ENC  amd64

>Description:
Removing the distributions rc.d script for a proper FreeBSD one.
>How-To-Repeat:
N/A.
>Fix:
Wrote a new one that is attached.

Patch contains changes:
- New file files/heartbeat.in
- Removed file files/patch-heartbeat-init.d-heartbeat.in
- Updated Makefile to copy it into place before build.

Patch attached with submission follows:

diff -ruN heartbeat.orig/Makefile heartbeat/Makefile
--- heartbeat.orig/Makefile	2009-09-10 18:48:15.000000000 -0500
+++ heartbeat/Makefile	2009-09-24 10:12:02.000000000 -0500
@@ -93,6 +93,7 @@
 
 pre-patch:
 	@${MV} ${WRKDIR}/Heartbeat-STABLE-2-1-${DISTNAME} ${WRKSRC}
+	@${CP} -f ${FILESDIR}/heartbeat.in ${WRKSRC}/heartbeat/init.d/
 
 post-patch:
 	@${LN} -s ${WRKSRC}/include/config.h ${WRKSRC}/config.h
diff -ruN heartbeat.orig/files/heartbeat.in heartbeat/files/heartbeat.in
--- heartbeat.orig/files/heartbeat.in	1969-12-31 18:00:00.000000000 -0600
+++ heartbeat/files/heartbeat.in	2009-09-24 10:16:01.000000000 -0500
@@ -0,0 +1,211 @@
+#!/bin/sh
+#
+
+# PROVIDE: heartbeat
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+#
+# Add the following line to /etc/rc.conf to enable heartbeat:
+#
+# heartbeat_enable="YES"		Set to NO by default.
+#								Set to YES to enable heartbeat.
+# heartbeat_gracefulstop="YES"	Set to NO by default.
+#								Set to YES to enable more graceful resource
+#								stopping behaviour at shutdown.
+
+# Includes
+. /etc/rc.subr
+HA_DIR=@sysconfdir@/ha.d; export HA_DIR
+. $HA_DIR/shellfuncs
+
+LOCKDIR=@localstatedir@/lock/subsys
+SUBSYS=heartbeat
+RUNDIR=@localstatedir@/run
+
+name="heartbeat"
+rcvar=`set_rcvar`
+
+load_rc_config $name
+: ${heartbeat_enable="NO"}
+: ${heartbeat_gracefulstop="NO"}
+
+start_cmd="${name}_start"
+stop_cmd="${name}_stop"
+reload_cmd="${name}_reload"
+restart_cmd="${name}_restart"
+gracefulstop_cmd="${name}_gracefulstop"
+command="$HA_BIN/heartbeat"
+pidfile="$RUNDIR/heartbeat.pid"
+required_files="$HA_DIR/ha.cf"
+
+if [ "$heartbeat_gracefulstop" = "YES" ]; then
+	stop_cmd="${name}_gracefulstop"
+fi
+
+heartbeat_checkyesno() {
+	case `ha_parameter $1 | tr '[A-Z]' '[a-z]'` in
+	
+		y|yes|enable|on|true|1|manual) true;;
+		
+		*) false;;
+	esac
+}
+
+heartbeat_gracefulstop() {
+	# Run cluster pre-stop
+	heartbeat_runstartstop pre-stop
+
+	# Stop heartbeat daemon
+	$HA_BIN/heartbeat -k >/dev/null 2>&1
+	RC=$?
+
+	sleeptime=$((`ha_parameter deadtime` + 10))
+	
+	echo -n "Sleeping $sleeptime seconds to allow complete resource takeover: "
+	sleep $sleeptime
+	echo "OK"
+
+	# ???
+	if [ $RC -eq 0 ]; then
+		rm -f $LOCKDIR/$SUBSYS
+	fi
+
+	# Run cluster post-stop
+	heartbeat_runstartstop post-stop $RC
+
+	# Stop Logd
+	logd_stop
+
+	return $RC
+}
+
+heartbeat_reload() {
+	# Re-reads configuration files. Will *keep* it's resources.
+	$HA_BIN/heartbeat -r >/dev/null 2>&1
+}
+
+heartbeat_restart() {
+	sleeptime=$((`ha_parameter deadtime` + 10))
+	
+	if `heartbeat_stop`; then
+		echo -n "Sleeping $sleeptime seconds to allow complete resource takeover: "
+		sleep $sleeptime
+		echo "OK"
+		echo ""
+		echo "Starting heartbeat."
+		heartbeat_start
+	else
+		echo "Heartbeat did not stop correctly."
+		exit 1
+	fi
+}
+
+heartbeat_runstartstop() {
+	# Run custom cluster commands before/after operations
+	if [ -f $HA_RESOURCEDIR/startstop ]; then
+		$HA_RESOURCEDIR/startstop  "$@"
+	fi
+}
+
+heartbeat_start() {
+
+	# Start Logd
+	logd_start
+	
+	# Run cluster pre-startup
+	heartbeat_runstartstop pre-start
+	
+	# Check if CRM enabled
+	if ! `heartbeat_checkyesno crm`; then
+	
+		# Heartbeat v1 configuration
+		$HA_NOARCHBIN/ResourceManager verifyallidle
+	fi
+	
+	# ???
+	rm -f $RUNDIR/ppp.d/*
+
+	if [ ! -d $RUNDIR/heartbeat ]; then
+		mkdir -p $RUNDIR/heartbeat/ccm
+		mkdir -p $RUNDIR/heartbeat/crm
+		chown -R @HA_CCMUSER@:@HA_APIGROUP@ $RUNDIR/heartbeat
+		chmod -R 750 $RUNDIR/heartbeat
+	fi
+
+	# Heartbeat v1 configuration files
+	if [ -f $HA_DIR/ipresources -a ! -f $HA_DIR/haresources ]; then
+		mv $HA_DIR/ipresources $HA_DIR/haresources
+	fi
+
+	# Start heartbeat daemon
+	$HA_BIN/heartbeat > /dev/null 2>&1
+	RC=$?
+	
+	# ???
+	if [ $RC -eq 0 ]; then
+		if [ ! -d $LOCKDIR ]; then
+			mkdir -p $LOCKDIR
+		fi
+		touch $LOCKDIR/$SUBSYS
+	fi
+
+	# Run cluster post-startup
+	heartbeat_runstartstop post-start $RC
+
+	return $RC
+}
+
+heartbeat_stop() {
+	# Run cluster pre-stop
+	heartbeat_runstartstop pre-stop
+
+	# Stop heartbeat daemon
+	$HA_BIN/heartbeat -k >/dev/null 2>&1
+	RC=$?
+
+	# ???
+	if [ $RC -eq 0 ]; then
+		rm -f $LOCKDIR/$SUBSYS
+	fi
+
+	# Run cluster post-stop
+	heartbeat_runstartstop post-stop $RC
+
+	# Stop Logd
+	logd_stop
+
+	return $RC
+}
+
+logd_start() {
+	# Check if enabled.
+	if `heartbeat_checkyesno use_logd`; then
+
+		# Check if running
+		if ! `$HA_BIN/ha_logd -s >/dev/null 2>&1`; then
+
+			# Start
+			if ! `$HA_BIN/ha_logd -d -c $HA_DIR/logd.cf >/dev/null 2>&1`; then
+				exit 1
+			fi
+		fi
+	fi
+}
+
+logd_stop() {
+	# Check if enabled.
+	if `heartbeat_checkyesno use_logd`; then
+
+		# Check if running
+		if `$HA_BIN/ha_logd -s >/dev/null 2>&1`; then
+
+			# Stop
+			$HA_BIN/ha_logd -k >/dev/null 2>&1
+		fi
+	fi
+}
+
+extra_commands="reload gracefulstop"
+run_rc_command "$1"
+
diff -ruN heartbeat.orig/files/patch-heartbeat-init.d-heartbeat.in heartbeat/files/patch-heartbeat-init.d-heartbeat.in
--- heartbeat.orig/files/patch-heartbeat-init.d-heartbeat.in	2009-07-29 04:13:31.000000000 -0500
+++ heartbeat/files/patch-heartbeat-init.d-heartbeat.in	1969-12-31 18:00:00.000000000 -0600
@@ -1,39 +0,0 @@
---- heartbeat/init.d/heartbeat.in.orig	2008-08-18 07:32:19.000000000 -0500
-+++ heartbeat/init.d/heartbeat.in	2008-10-16 02:49:27.000000000 -0500
-@@ -45,6 +45,27 @@
- ### END INIT INFO
- 
- 
-+# FreeBSD
-+# PROVIDE: heartbeat
-+# REQUIRE: LOGIN
-+# KEYWORD: shutdown
-+
-+# Add the following line to /etc/rc.conf to enable heartbeat:
-+# heartbeat_enable="YES"
-+
-+. /etc/rc.subr
-+name="heartbeat"
-+rcvar='set_rcvar'
-+load_rc_config $name
-+: ${heartbeat_enable="NO"}
-+
-+if ! checkyesno "heartbeat_enable"; then
-+	exit 0
-+fi
-+
-+set `echo $1 | sed s/fast//`
-+
-+
- HA_DIR=@sysconfdir@/ha.d; export HA_DIR
- CONFIG=$HA_DIR/ha.cf
- . $HA_DIR/shellfuncs
-@@ -161,7 +182,7 @@
-     fi
-     
- 
--    $HA_BIN/ha_logd -d >/dev/null 2>&1
-+    $HA_BIN/ha_logd -d -c $HA_DIR/logd.cf >/dev/null 2>&1
-     if 
- 	[ $? -ne 0 ]
-     then


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909251334.n8PDYBQG085939>