summaryrefslogtreecommitdiff
path: root/sys-cluster/galera/files/garb.init
blob: 6da7a758228676b8c23fbb967dd2c249f058a2b0 (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
#!/sbin/openrc-run
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

command="/usr/bin/garbd"
pidfile="${PIDFILE:-/var/run/garbd}"
command_background="yes"
command_args=""
command_user="nobody"

depend() {
	use net
	after mysql
}

start_pre() {
	if [ -z "${GALERA_NODES}" ]; then
		eerror "List of GALERA_NODES is not configured"
		return 1
	fi

	if [ -z "${GALERA_GROUP}" ]; then
		eerror "GALERA_GROUP name is not configured"
		return 1
	fi

	GALERA_PORT=${GALERA_PORT:-4567}

	local nodes=$(echo "${GALERA_NODES}" | awk '{ gsub(" ", ",") ; print $0 }')
	local OPTIONS="-a gcomm://${nodes} -g ${GALERA_GROUP}"
	[ -n "${GALERA_OPTIONS}" ] && OPTIONS="${OPTIONS} -o ${GALERA_OPTIONS}"
	[ -n "${LOG_FILE}" ]       && OPTIONS="${OPTIONS} -l ${LOG_FILE}"
	[ -n "${NODE_NAME}" ]      && OPTIONS="${OPTIONS} -n ${NODE_NAME}"

	command_args="${OPTIONS}"
}