. "${CTDB_BASE}/functions"
-loadconfig
+load_system_config "ctdb"
ctdbd="${CTDBD:-/usr/local/sbin/ctdbd}"
############################################################
-# If necessary, mount volatile database directory on tmpfs
-dbdir_tmpfs_start ()
-{
- if [ -z "$CTDB_DBDIR_TMPFS_OPTIONS" ] ; then
- return
- fi
-
- # Shortcut for readability
- _opts="$CTDB_DBDIR_TMPFS_OPTIONS"
-
- mkdir -p "$CTDB_DBDIR" || exit $?
-
- # If already mounted then remount, otherwise mount
- if findmnt -t tmpfs "$CTDB_DBDIR" >/dev/null ; then
- mount -t tmpfs -o "remount,$_opts" none "$CTDB_DBDIR" || \
- exit $?
- else
- mount -t tmpfs -o "$_opts" none "$CTDB_DBDIR" || exit $?
- fi
-}
-
-# If necessary, unmount volatile database tmpfs directory on exit
-dbdir_tmpfs_stop ()
-{
- if [ -z "$CTDB_DBDIR_TMPFS_OPTIONS" ] ; then
- return
- fi
-
- if [ -d "$CTDB_DBDIR" ] && findmnt -t tmpfs "$CTDB_DBDIR" >/dev/null ; then
- umount "$CTDB_DBDIR"
- fi
-}
-
-# Only the nested function references its arguments
-# shellcheck disable=SC2120
-build_ctdb_options ()
-{
- ctdb_options=""
-
- maybe_set ()
- {
- # If the given variable isn't set then do nothing
- [ -n "$2" ] || return
- # If a required value for the variable and it doesn't match,
- # then do nothing
- [ -z "$3" -o "$3" = "$2" ] || return
-
- val="'$2'"
- case "$1" in
- --*) sep="=" ;;
- -*) sep=" " ;;
- esac
- # For these options we're only passing a value-less flag.
- if [ -n "$3" ] ; then
- val=""
- sep=""
- fi
-
- ctdb_options="${ctdb_options}${ctdb_options:+ }${1}${sep}${val}"
- }
-
- if [ -z "$CTDB_RECOVERY_LOCK" ] ; then
- echo "No recovery lock specified. Starting CTDB without split brain prevention."
- fi
- maybe_set "--reclock" "$CTDB_RECOVERY_LOCK"
-
- # build up ctdb_options variable from optional parameters
- maybe_set "--logging" "$CTDB_LOGGING"
- maybe_set "--listen" "$CTDB_NODE_ADDRESS"
- maybe_set "--dbdir" "$CTDB_DBDIR"
- maybe_set "--dbdir-persistent" "$CTDB_DBDIR_PERSISTENT"
- maybe_set "--dbdir-state" "$CTDB_DBDIR_STATE"
- maybe_set "--transport" "$CTDB_TRANSPORT"
- maybe_set "-d" "$CTDB_DEBUGLEVEL"
- maybe_set "--notification-script" "$CTDB_NOTIFY_SCRIPT"
- maybe_set "--start-as-disabled" "$CTDB_START_AS_DISABLED" "yes"
- maybe_set "--start-as-stopped " "$CTDB_START_AS_STOPPED" "yes"
- maybe_set "--no-recmaster" "$CTDB_CAPABILITY_RECMASTER" "no"
- maybe_set "--no-lmaster" "$CTDB_CAPABILITY_LMASTER" "no"
- maybe_set "--nosetsched" "$CTDB_NOSETSCHED" "yes"
- maybe_set "--script-log-level" "$CTDB_SCRIPT_LOG_LEVEL"
- maybe_set "--max-persistent-check-errors" "$CTDB_MAX_PERSISTENT_CHECK_ERRORS"
-}
-
-export_debug_variables ()
-{
- [ -n "$CTDB_DEBUG_HUNG_SCRIPT" ] && export CTDB_DEBUG_HUNG_SCRIPT
- [ -n "$CTDB_DEBUG_LOCKS" ] && export CTDB_DEBUG_LOCKS
-}
-
-############################################################
-
start()
{
- dbdir_tmpfs_start
-
- # build_ctdb_options() takes no arguments
- # shellcheck disable=SC2119
- build_ctdb_options
-
- export_debug_variables
-
- # Explicitly trying to disable core files, no other way
- # shellcheck disable=SC2039
- if [ "$CTDB_SUPPRESS_COREFILE" = "yes" ]; then
- ulimit -c 0
- else
- ulimit -c unlimited
- fi
-
- # Unsupported option easily avoided by not using configuration variable
- # shellcheck disable=SC2039
- if [ -n "$CTDB_MAX_OPEN_FILES" ]; then
- ulimit -n "$CTDB_MAX_OPEN_FILES"
- fi
-
- if [ -n "$CTDB_VALGRIND" -a "$CTDB_VALGRIND" != "no" ] ; then
- if [ "$CTDB_VALGRIND" = "yes" ] ; then
- ctdbd="valgrind -q --log-file=/usr/local/var/log/ctdb_valgrind ${ctdbd}"
- else
- ctdbd="${CTDB_VALGRIND} ${ctdbd}"
- fi
- ctdb_options="${ctdb_options} --valgrinding"
- fi
-
- case "$CTDB_LOGGING" in
- syslog:udp|syslog:udp-rfc5424)
- logger -t ctdbd "CTDB is being run with ${CTDB_LOGGING}. If nothing is logged then check your syslogd configuration"
- ;;
- syslog|syslog:*) : ;;
- file:*)
- logger -t ctdbd "CTDB is being run without syslog enabled. Logs will be in ${CTDB_LOGGING#file:}"
- ;;
- *)
- logger -t ctdbd "CTDB is being run without syslog enabled. Logs will be in log.ctdb"
- esac
-
- eval "$ctdbd" "$ctdb_options" || return 1
+ eval "$ctdbd" || return 1
# Wait until ctdbd has started and is ready to respond to clients.
_timeout="${CTDB_STARTUP_TIMEOUT:-10}"
return 1
fi
- dbdir_tmpfs_stop
-
return 0
}