5da900288b29c55681814a27251ec343e77b771e
[samba.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 public_addresses=""
23         local no_event_scripts=false
24         local disable_failover=""
25         local reclock_use_command=""
26         case "$1" in
27         --no-public-addresses) public_addresses="/dev/null" ;;
28         --no-event-scripts)    no_event_scripts=true    ;;
29         --disable-failover)    disable_failover="yes"   ;;
30         --reclock-use-command) reclock_use_command="yes" ;;
31         esac
32
33         $ctdb_local_daemons setup \
34                 -n "$TEST_LOCAL_DAEMONS" \
35                 ${disable_failover:+-F} \
36                 ${public_addresses:+-P} ${public_addresses} \
37                 ${CTDB_USE_IPV6:+-6} \
38                 ${reclock_use_command:+-R} \
39                 ${TEST_SOCKET_WRAPPER_SO_PATH:+-S} ${TEST_SOCKET_WRAPPER_SO_PATH}
40         if [ $? -ne 0 ] ; then
41                 exit 1
42         fi
43
44         local pnn
45         for pnn in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
46                 if $no_event_scripts ; then
47                         rm -vf "${CTDB_BASE}/events/legacy/"*
48                 fi
49         done
50 }
51
52 start_ctdb_1 ()
53 {
54         local pnn="$1"
55
56         $ctdb_local_daemons start "$pnn"
57 }
58
59 ctdb_start_all ()
60 {
61         $ctdb_local_daemons start "all"
62 }
63
64 stop_ctdb_1 ()
65 {
66         local pnn="$1"
67
68         $ctdb_local_daemons stop "$pnn"
69 }
70
71 ctdb_stop_all ()
72 {
73         $ctdb_local_daemons stop "all"
74 }
75
76 restart_ctdb_1 ()
77 {
78         stop_ctdb_1 "$1"
79         start_ctdb_1 "$1"
80 }
81
82 # onnode just needs the nodes file, so use the common one
83 export CTDB_BASE="$SIMPLE_TESTS_VAR_DIR"