summaryrefslogtreecommitdiff
path: root/ctdb/tests/simple/scripts/local_daemons.bash
blob: 327c69a9ea9a2820f4ae0f0ba38737e80b49c724 (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
# Hey Emacs, this is a -*- shell-script -*- !!!  :-)

hdir="$CTDB_SCRIPTS_HELPER_BINDIR"
export CTDB_EVENT_HELPER="${hdir}/ctdb-event"

if $CTDB_TESTS_ARE_INSTALLED ; then
	# Find it in $PATH
	helper="ctdb_local_daemons"
else
	helper="${CTDB_TEST_DIR}/local_daemons.sh"
fi

ctdb_local_daemons="${helper} ${CTDB_TEST_TMP_DIR}"

#######################################

setup_ctdb ()
{
	local no_event_scripts=false

	# All other options are passed through to local_daemons.sh setup
	case "$1" in
	--no-event-scripts) no_event_scripts=true ; shift ;;
	esac

	$ctdb_local_daemons setup "$@" \
		-n "$TEST_LOCAL_DAEMONS" \
		${CTDB_USE_IPV6:+-6} \
		${TEST_SOCKET_WRAPPER_SO_PATH:+-S ${TEST_SOCKET_WRAPPER_SO_PATH}}
	# Burying the above in an if-statement condition reduces readability.
	# shellcheck disable=SC2181
	if [ $? -ne 0 ] ; then
		exit 1
	fi

	if $no_event_scripts ; then
		local pnn
		for pnn in $(seq 0 $((TEST_LOCAL_DAEMONS - 1))) ; do
			rm -vf "${CTDB_BASE}/events/legacy/"*
		done
	fi
}

start_ctdb_1 ()
{
	local pnn="$1"

	$ctdb_local_daemons start "$pnn"
}

ctdb_start_all ()
{
	$ctdb_local_daemons start "all"
}

stop_ctdb_1 ()
{
	local pnn="$1"

	$ctdb_local_daemons stop "$pnn"
}

ctdb_stop_all ()
{
	$ctdb_local_daemons stop "all"
}

restart_ctdb_1 ()
{
	stop_ctdb_1 "$1"
	start_ctdb_1 "$1"
}

onnode ()
{
	$ctdb_local_daemons onnode "$@"
}