3 # ctdbd wrapper - start or stop CTDB
7 echo "usage: ctdbd_wrapper { start | stop }"
15 ############################################################
17 if [ -z "$CTDB_BASE" ] ; then
18 export CTDB_BASE="/usr/local/etc/ctdb"
21 . "${CTDB_BASE}/functions"
25 ctdbd="${CTDBD:-/usr/local/sbin/ctdbd}"
27 ############################################################
29 # Only the nested function references its arguments
30 # shellcheck disable=SC2120
37 # If the given variable isn't set then do nothing
39 # If a required value for the variable and it doesn't match,
41 [ -z "$3" -o "$3" = "$2" ] || return
48 # For these options we're only passing a value-less flag.
54 ctdb_options="${ctdb_options}${ctdb_options:+ }${1}${sep}${val}"
57 # build up ctdb_options variable from optional parameters
58 maybe_set "--reclock" "$CTDB_RECOVERY_LOCK"
59 maybe_set "--logging" "$CTDB_LOGGING"
60 maybe_set "--listen" "$CTDB_NODE_ADDRESS"
61 maybe_set "--dbdir" "$CTDB_DBDIR"
62 maybe_set "--dbdir-persistent" "$CTDB_DBDIR_PERSISTENT"
63 maybe_set "--dbdir-state" "$CTDB_DBDIR_STATE"
64 maybe_set "--transport" "$CTDB_TRANSPORT"
65 maybe_set "-d" "$CTDB_DEBUGLEVEL"
66 maybe_set "--start-as-disabled" "$CTDB_START_AS_DISABLED" "yes"
67 maybe_set "--start-as-stopped " "$CTDB_START_AS_STOPPED" "yes"
68 maybe_set "--no-recmaster" "$CTDB_CAPABILITY_RECMASTER" "no"
69 maybe_set "--no-lmaster" "$CTDB_CAPABILITY_LMASTER" "no"
70 maybe_set "--nosetsched" "$CTDB_NOSETSCHED" "yes"
71 maybe_set "--script-log-level" "$CTDB_SCRIPT_LOG_LEVEL"
74 export_debug_variables ()
76 [ -n "$CTDB_DEBUG_HUNG_SCRIPT" ] && export CTDB_DEBUG_HUNG_SCRIPT
77 [ -n "$CTDB_DEBUG_LOCKS" ] && export CTDB_DEBUG_LOCKS
80 ############################################################
84 # build_ctdb_options() takes no arguments
85 # shellcheck disable=SC2119
88 export_debug_variables
90 eval "$ctdbd" "$ctdb_options" || return 1
92 # Wait until ctdbd has started and is ready to respond to clients.
93 _timeout="${CTDB_STARTUP_TIMEOUT:-10}"
95 while [ "$_count" -lt "$_timeout" ] ; do
96 if $CTDB runstate first_recovery startup running >/dev/null 2>&1 ; then
100 _count=$((_count + 1))
104 echo "Timed out waiting for initialisation - check logs"
105 # Attempt a shutdown just in case things are still running
106 $CTDB shutdown >/dev/null 2>&1
107 drop_all_public_ips >/dev/null 2>&1
115 # The above command is important and needs to stand out, so
116 # post-check exit status
117 # shellcheck disable=SC2181
118 if [ $? -ne 0 ] ; then
119 echo "Error while shutting down CTDB"
120 drop_all_public_ips >/dev/null 2>&1
127 ############################################################
129 # Allow notifications for start/stop.
130 if [ -x "$CTDB_BASE/rc.ctdb" ] ; then
131 "$CTDB_BASE/rc.ctdb" "$action"
138 echo "usage: $0 {start|stop}"