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"
72 maybe_set "--max-persistent-check-errors" "$CTDB_MAX_PERSISTENT_CHECK_ERRORS"
75 export_debug_variables ()
77 [ -n "$CTDB_DEBUG_HUNG_SCRIPT" ] && export CTDB_DEBUG_HUNG_SCRIPT
78 [ -n "$CTDB_DEBUG_LOCKS" ] && export CTDB_DEBUG_LOCKS
81 ############################################################
85 # build_ctdb_options() takes no arguments
86 # shellcheck disable=SC2119
89 export_debug_variables
91 eval "$ctdbd" "$ctdb_options" || return 1
93 # Wait until ctdbd has started and is ready to respond to clients.
94 _timeout="${CTDB_STARTUP_TIMEOUT:-10}"
96 while [ "$_count" -lt "$_timeout" ] ; do
97 if $CTDB runstate first_recovery startup running >/dev/null 2>&1 ; then
101 _count=$((_count + 1))
105 echo "Timed out waiting for initialisation - check logs"
106 # Attempt a shutdown just in case things are still running
107 $CTDB shutdown >/dev/null 2>&1
108 drop_all_public_ips >/dev/null 2>&1
116 # The above command is important and needs to stand out, so
117 # post-check exit status
118 # shellcheck disable=SC2181
119 if [ $? -ne 0 ] ; then
120 echo "Error while shutting down CTDB"
121 drop_all_public_ips >/dev/null 2>&1
128 ############################################################
130 # Allow notifications for start/stop.
131 if [ -x "$CTDB_BASE/rc.ctdb" ] ; then
132 "$CTDB_BASE/rc.ctdb" "$action"
139 echo "usage: $0 {start|stop}"