summaryrefslogtreecommitdiff
blob: 961eb3c8d91d47aa0ebf37426032f0ec106637ed (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit autotools eutils flag-o-matic

DESCRIPTION="Heartbeat High-Availability Cluster Manager"
HOMEPAGE="http://www.linux-ha.org"
SRC_URI="http://www.linux-ha.org/download/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="crm doc ipmi ldirectord snmp"

RDEPEND="
	=dev-libs/glib-2*
	dev-libs/libxml2
	net-libs/libnet
	>=dev-lang/perl-5.8.8
	>=dev-lang/python-2.4
	>=dev-python/pyxml-0.8
	net-misc/iputils
	virtual/ssh
	net-libs/gnutls
	ldirectord? (
		sys-cluster/ipvsadm
		dev-perl/Net-DNS
		dev-perl/libwww-perl
		dev-perl/perl-ldap
		virtual/perl-libnet
		dev-perl/Crypt-SSLeay
		dev-perl/HTML-Parser
		dev-perl/perl-ldap
		dev-perl/Mail-IMAPClient
		dev-perl/Mail-POP3Client
		dev-perl/MailTools
	)
	snmp? ( net-analyzer/net-snmp )
	net-misc/telnet-bsd
	ipmi? (
		>=sys-libs/openipmi-2
	)
"
DEPEND="${RDEPEND}
	dev-lang/swig
	dev-util/pkgconfig
"

# let the user override the user and group defaults
# WARNING! ATTENTION! if you plan to use DRBD for cluster storage,
# please note that /sbin/drbdmeta and /sbin/drbdsetup need to
# be SUID root and executable by ${HA_GROUP_NAME}!
# otherwise, Heartbeat will not be able to handle DRBD correctly.
test -z "${HA_GROUP_ID}"   && HA_GROUP_ID='65'
test -z "${HA_GROUP_NAME}" && HA_GROUP_NAME='haclient'
test -z "${HA_USER_ID}"    && HA_USER_ID='65'
test -z "${HA_USER_NAME}"  && HA_USER_NAME='hacluster'
test -z "${HA_USER_HOME}"  && HA_USER_HOME='/var/lib/heartbeat'

pkg_setup() {
	# check for heartbeat/HA group
	if ! egetent group ${HA_GROUP_NAME} >&/dev/null; then
		# check for an existing group name with another gid
		local existing_group_name=$(egetent group ${HA_GROUP_ID} | cut -d : -f 1)
		if [[ -n "${existing_group_name}" ]] && \
			[[ "${existing_group_name}" != "${HA_GROUP_NAME}" ]]; then
			eerror
			eerror "an existing group with gid '${HA_GROUP_ID}' and a"
			eerror "name other than '${HA_GROUP_NAME}' has been found"
			eerror "on your system. either remove the user or change"
			eerror "the uid to another one."
			eerror
			die "system group name problem"
		fi
		# create the new group
		enewgroup ${HA_GROUP_NAME} ${HA_GROUP_ID}
	else
		# check for an existing gid with another group name
		local existing_group_id=$(egetent group ${HA_GROUP_NAME} | cut -d : -f 3)
		if [[ -n "${existing_group_id}" ]] && \
			[[ "${existing_group_id}" != "${HA_GROUP_ID}" ]]; then
			eerror
			eerror "an existing group with the name '${HA_GROUP_NAME}' and a"
			eerror "gid other than '${HA_GROUP_ID}' has been found"
			eerror "on your system. either remove the group or change"
			eerror "the name to another one."
			eerror
			die "system group id problem"
		fi
	fi

	# check for heartbeat/HA user
	if ! egetent passwd ${HA_USER_NAME} >&/dev/null; then
		# check for an existing user name with another uid
		local existing_user_name=$(egetent passwd ${HA_USER_ID} | cut -d : -f 1)
		if [[ -n "${existing_user_name}" ]] && \
			[[ "${existing_user_name}" != "${HA_USER_NAME}" ]]; then
			eerror
			eerror "an existing user with uid '${HA_USER_ID}' and a"
			eerror "name other than '${HA_USER_NAME}' has been found"
			eerror "on your system. either remove the user or change"
			eerror "the uid to another one."
			eerror
			die "system user name problem"
		fi
		# create the new user
		enewuser ${HA_USER_NAME} ${HA_USER_ID} -1 ${HA_USER_HOME} ${HA_GROUP_NAME}
	else
		# check for an existing uid with another user name
		local existing_user_id=$(egetent passwd ${HA_USER_NAME} | cut -d : -f 3)
		if [[ -n "${existing_user_id}" ]] && \
			[[ "${existing_user_id}" != "${HA_USER_ID}" ]]; then
			eerror
			eerror "an existing user with the name '${HA_USER_NAME}' and a"
			eerror "uid other than '${HA_USER_ID}' has been found"
			eerror "on your system. either remove the user or change"
			eerror "the name to another one."
			eerror
			die "system user id problem"
		fi
	fi

	# check for USE flag constraints
	if ! use crm && use snmp; then
		die "USE=snmp requires USE=crm (disable USE=snmp or enable USE=crm)"
	fi
}

src_unpack() {
	unpack ${A}
	cd "${S}"
	use crm || epatch "${FILESDIR}"/${P}-nocrm-dopd.patch

	# http://developerbugs.linux-foundation.org/show_bug.cgi?id=1833#c6
	# http://hg.linux-ha.org/dev/rev/54723736ab18
	epatch "${FILESDIR}"/${P}-lrm-op_status.patch
	# http://developerbugs.linux-foundation.org/show_bug.cgi?id=1833#c11
	epatch "${FILESDIR}"/${P}-lrmadmin-cts.patch

	# http://developerbugs.linux-foundation.org/show_bug.cgi?id=1849#c6
	epatch "${FILESDIR}"/${P}-leapyear-rewrite.patch

	# http://hg.linux-ha.org/dev/rev/47f60bebe7b2
	epatch "${FILESDIR}"/${P}-dopd-47f60bebe7b2.patch

	eautoreconf
}

src_compile() {
	# FIXME
	if use ipmi; then
		eerror "Sorry, integrated IPMI STONITH support is broken in 2.1.3."
		die "Please disable the ipmi USE flag and try again."
	fi
	econf \
		--localstatedir=/var \
		--with-group-name=${HA_GROUP_NAME} \
		--with-group-id=${HA_GROUP_ID} \
		--with-ccmuser-name=${HA_USER_NAME} \
		--with-ccmuser-id=${HA_USER_ID} \
		--disable-rpath \
		--disable-fatal-warnings \
		$(use_enable snmp) \
		$(use_enable snmp snmp-subagent) \
		$(use_enable ipmi ipmilan) \
		--enable-checkpointd \
		--enable-quorumd \
		--enable-dopd \
		$(use_enable crm) \
		--enable-lrm \
		--disable-mgmt \
		|| die "configure failed"
	emake -j 1 || die "make failed"
}

src_install() {
	# FIXME: convert to emake?
	make DESTDIR="${D}" install || die "make install failed"

	# heartbeat modules need these dirs
	# FIXME: is this (not) needed?
	#keepdir /var/lib/heartbeat/ckpt /var/lib/heartbeat/ccm /var/lib/heartbeat

	keepdir \
		/etc/ha.d/conf \
		/var/lib/heartbeat/{ccm,ckpt,lrm,fencing} \
		/var/lib/heartbeat/cores/{${HA_USER_NAME},root,nobody} \
		/var/run/heartbeat/ccm

	if use crm; then
		keepdir \
			/var/lib/heartbeat/crm \
			/var/lib/heartbeat/pengine \
			/var/run/heartbeat/crm
	else
		rm "${D}"/usr/lib/heartbeat/haresources2cib.py
	fi

	dosym /usr/sbin/ldirectord /etc/ha.d/resource.d/ldirectord

	if ! useq ldirectord; then
		rm \
			"${D}"/etc/init.d/ldirectord
			"${D}"/etc/logrotate.d/ldirectord \
			"${D}"/etc/ha.d/resource.d/ldirectord \
			"${D}"/usr/share/man/man8/supervise-ldirectord-config.8 \
			"${D}"/usr/share/man/man8/ldirectord.8 \
			"${D}"/usr/sbin/ldirectord \
			"${D}"/usr/sbin/supervise-ldirectord-config
	fi

	newinitd "${FILESDIR}"/heartbeat.init-r2 heartbeat

	dodoc \
		README \
		doc/*.{cf,txt} \
		doc/{haresources,authkeys,AUTHORS,COPYING} \
		ldirectord/ldirectord.cf
}

pkg_postinst() {
	ewarn
	ewarn "Notice for DRBD users:"
	ewarn
	ewarn "DRBD Outdate Peer Daemon (dopd) was broken as of Heartbeat 2.1.3."
	ewarn "This ebuild includes a patch from the DRBD developers which should"
	ewarn "fix the corresponding bugs. If you were previously using the"
	ewarn "provided wrapper script, please switch back to the real"
	ewarn "drbd-peer-outdater path in /etc/drbd.conf."
	ewarn
}