95af943f6d79daa7004a87c58f6935163a4410bf
[metze/samba/wip.git] / ctdb / tests / simple / scripts / local_daemons.bash
1 # Hey Emacs, this is a -*- shell-script -*- !!!  :-)
2
3 hdir="$CTDB_SCRIPTS_HELPER_BINDIR"
4 export CTDB_EVENT_HELPER="${hdir}/ctdb-event"
5
6 if $CTDB_TESTS_ARE_INSTALLED ; then
7         # Find it in $PATH
8         helper="ctdb_local_daemons"
9 else
10         helper="${CTDB_TEST_DIR}/local_daemons.sh"
11 fi
12
13 ctdb_local_daemons="${helper} ${SIMPLE_TESTS_VAR_DIR}"
14
15 # onnode will execute this, which fakes ssh against local daemons
16 export ONNODE_SSH="${ctdb_local_daemons} ssh"
17
18 #######################################
19
20 setup_ctdb ()
21 {
22         local no_event_scripts=false
23
24         # All other options are passed through to local_daemons.sh setup
25         case "$1" in
26         --no-event-scripts) no_event_scripts=true ; shift ;;
27         esac
28
29         $ctdb_local_daemons setup "$@" \
30                 -n "$TEST_LOCAL_DAEMONS" \
31                 ${CTDB_USE_IPV6:+-6} \
32                 ${TEST_SOCKET_WRAPPER_SO_PATH:+-S ${TEST_SOCKET_WRAPPER_SO_PATH}}
33         # Burying the above in an if-statement condition reduces readability.
34         # shellcheck disable=SC2181
35         if [ $? -ne 0 ] ; then
36                 exit 1
37         fi
38
39         if $no_event_scripts ; then
40                 local pnn
41                 for pnn in $(seq 0 $((TEST_LOCAL_DAEMONS - 1))) ; do
42                         rm -vf "${CTDB_BASE}/events/legacy/"*
43                 done
44         fi
45 }
46
47 start_ctdb_1 ()
48 {
49         local pnn="$1"
50
51         $ctdb_local_daemons start "$pnn"
52 }
53
54 ctdb_start_all ()
55 {
56         $ctdb_local_daemons start "all"
57 }
58
59 stop_ctdb_1 ()
60 {
61         local pnn="$1"
62
63         $ctdb_local_daemons stop "$pnn"
64 }
65
66 ctdb_stop_all ()
67 {
68         $ctdb_local_daemons stop "all"
69 }
70
71 restart_ctdb_1 ()
72 {
73         stop_ctdb_1 "$1"
74         start_ctdb_1 "$1"
75 }
76
77 # onnode just needs the nodes file, so use the common one
78 export CTDB_BASE="$SIMPLE_TESTS_VAR_DIR"