summaryrefslogtreecommitdiff
blob: 1de6fc5862e4e762260c253c2dd79b55e8debf8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-cluster/heartbeat/files/heartbeat-init,v 1.8 2012/10/29 16:44:23 ultrabug Exp $

HA_DIR=/etc/ha.d
. $HA_DIR/shellfuncs

depend() {
	use logger
	need net
}

opts="start stop status reload restart"

CheckBool() {
	case `echo "$1" | tr A-Z a-z` in
		y|yes|enable|on|true|1)     true;;
		*)                          false;;
	esac
}

# Run pre-startup script if it exists
RunStartStop() {
	[ -f $HA_DIR/resource.d/startstop ] && $HA_DIR/resource.d/startstop  "$@"
}

start() {
	checkpath -q -d -m 0755 -o root:root /var/run/heartbeat

	ebegin "Starting heartbeat"

	. $HA_DIR/shellfuncs

	# start the log subsystem
	CheckBool "`ha_parameter use_logd`" && \
	 ( /usr/lib/heartbeat/ha_logd -s &>/dev/null || \
           /usr/lib/heartbeat/ha_logd -d -c /etc/ha.d/ha_logd.cf)

	RunStartStop pre-start

	CheckBool "`ha_parameter crm`" || \
		/usr/lib/heartbeat/ResourceManager verifyallidle

	/usr/lib/heartbeat/heartbeat &>/dev/null
	ret=$?

	RunStartStop post-start

	eend ${ret}
}

stop() {
	ebegin "Stopping heartbeat"

	RunStartStop pre-stop

	/usr/lib/heartbeat/heartbeat -k &>/dev/null
	ret=$?

	RunStartStop post-stop ${ret}

	# stop log subsystem
	CheckBool "`ha_parameter use_logd`" && \
	( /usr/lib/heartbeat/ha_logd -s &>/dev/null && \
          /usr/lib/heartbeat/ha_logd -k &>/dev/null )

	eend ${ret}
}

status() {
	/usr/lib/heartbeat/heartbeat -s
}

reload() {
	ebegin "Reloading heartbeat"
	/usr/lib/heartbeat/heartbeat -r &>/dev/null
	eend $?
}

restart() {
	. $HA_DIR/shellfuncs

	sleeptime=$(( `ha_parameter deadtime` + 10 ))

	svc_stop

	ebegin "  waiting ${sleeptime}s to allow resource takeover to complete"
	sleep ${sleeptime}
	eend 0

	svc_start
}