Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enable possilbity to set a custom Galera node name to Galera ar… #221

Open
wants to merge 1 commit into
base: 3.x-5.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions garb/files/freebsd/garb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# (default empty).
# garb_galera_group (str): Galera cluster name, should be the same as on the rest of the nodes.
# (default empty).
# garb_galera_node_name (str): Galera node name, if not set default is "garb"
#
# Optional:
# garb_galera_options (str): Optional Galera internal options string (e.g. SSL settings)
# see http://www.codership.com/wiki/doku.php?id=galera_parameters
Expand All @@ -32,6 +34,7 @@ load_rc_config $name

# set defaults
: ${garb_enable="NO"}
: ${garb_galera_node_name=""}
: ${garb_galera_nodes=""}
: ${garb_galera_group=""}
: ${garb_galera_options=""}
Expand Down Expand Up @@ -70,9 +73,10 @@ garb_prestart()
done

command_args="$command_args -a gcomm://$ADDRESS"
[ -n "$garb_galera_group" ] && command_args="$command_args -g $garb_galera_group"
[ -n "$garb_galera_options" ] && command_args="$command_args -o $garb_galera_options"
[ -n "$garb_log_file" ] && command_args="$command_args -l $garb_log_file"
[ -n "$garb_galera_node_name" ] && command_args="$command_args -n $garb_galera_node_name"
[ -n "$garb_galera_group" ] && command_args="$command_args -g $garb_galera_group"
[ -n "$garb_galera_options" ] && command_args="$command_args -o $garb_galera_options"
[ -n "$garb_log_file" ] && command_args="$command_args -l $garb_log_file"
return 0
}

Expand Down
16 changes: 6 additions & 10 deletions garb/files/garb-systemd
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
#!/bin/bash -ue
#


config=/etc/sysconfig/garb

log_failure() {
echo " ERROR! $@"
echo " ERROR! $*"
}



program_start() {
echo "Starting garbd"
/usr/bin/garbd "$@"
}


start() {

if grep -q -E '^# REMOVE' $config;then
log_failure "Garbd config $config is not configured yet"
return 0
Expand All @@ -38,15 +34,15 @@ start() {
OPTIONS="-a gcomm://${GALERA_NODES// /,}"
# substitute space with comma for backward compatibility

[ -n "${GALERA_GROUP:-}" ] && OPTIONS="$OPTIONS -g '$GALERA_GROUP'"
[ -n "${GALERA_OPTIONS:-}" ] && OPTIONS="$OPTIONS -o '$GALERA_OPTIONS'"
[ -n "${LOG_FILE:-}" ] && OPTIONS="$OPTIONS -l '$LOG_FILE'"
[ -n "${GALERA_NODE_NAME:-}" ] && OPTIONS="$OPTIONS -n '$GALERA_NODE_NAME'"
[ -n "${GALERA_GROUP:-}" ] && OPTIONS="$OPTIONS -g '$GALERA_GROUP'"
[ -n "${GALERA_OPTIONS:-}" ] && OPTIONS="$OPTIONS -o '$GALERA_OPTIONS'"
[ -n "${LOG_FILE:-}" ] && OPTIONS="$OPTIONS -l '$LOG_FILE'"

eval program_start $OPTIONS
eval program_start "${OPTIONS}"
}



# See how we were called.
case "$1" in
start)
Expand Down
3 changes: 3 additions & 0 deletions garb/files/garb.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

# REMOVE THIS AFTER CONFIGURATION

# Galera node name. Default value if empty is "garb"
# GALERA_NODE_NAME=""

# A comma-separated list of node addresses (address[:port]) in the cluster
# GALERA_NODES=""

Expand Down
32 changes: 20 additions & 12 deletions garb/files/garb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,20 @@ _SYSTEMCTL_SKIP_REDIRECT=true

# Source function library.
if [ -f /etc/redhat-release ]; then
# shellcheck disable=SC1091
. /etc/init.d/functions
# shellcheck disable=SC1091
. /etc/sysconfig/network
config=/etc/sysconfig/garb
else
# shellcheck disable=SC1091
. /lib/lsb/init-functions
config=/etc/default/garbd
fi

log_failure() {
if [ -f /etc/redhat-release ]; then
echo -n $*
echo -n "$@"
failure "$*"
echo
else
Expand All @@ -58,10 +61,10 @@ program_start() {
local rcode
local gpid
if [ -f /etc/redhat-release ]; then
if [ -r $PIDFILE ];then
if [ -r $PIDFILE ]; then
gpid=$(cat $PIDFILE)
echo -n $"Stale pid file found at $PIDFILE"
if [[ -n ${gpid:-} ]] && kill -0 $gpid;then
if [[ -n ${gpid:-} ]] && kill -0 "${gpid}"; then
echo -n $"Garbd already running wiht PID $gpid"
exit 17
else
Expand All @@ -78,10 +81,10 @@ program_start() {
echo
else

if [ -r $PIDFILE ];then
if [ -r $PIDFILE ]; then
gpid=$(cat $PIDFILE)
log_daemon_msg "Stale pid file found at $PIDFILE"
if [[ -n ${gpid:-} ]] && kill -0 $gpid;then
if [[ -n ${gpid:-} ]] && kill -0 "${gpid}"; then
log_daemon_msg "Garbd already running wiht PID $gpid"
exit 17
else
Expand Down Expand Up @@ -112,7 +115,11 @@ program_stop() {
echo -n $"Shutting down $prog: "
killproc -p $PIDFILE
rcode=$?
[ $rcode -eq 0 ] && echo_success || echo_failure
if [ $rcode -eq 0 ]; then
echo_success
else
echo_failure
fi
else
start-stop-daemon --stop --quiet --oknodo --retry TERM/30/KILL/5 \
--pidfile $PIDFILE
Expand All @@ -137,8 +144,8 @@ start() {

if [ -r $PIDFILE ]; then
local PID=$(cat ${PIDFILE})
if ps -p $PID >/dev/null 2>&1; then
log_failure "$prog is already running with PID $PID"
if ps -p "${PID}" >/dev/null 2>&1; then
log_failure "$prog is already running with PID ${PID}"
return 3 # ESRCH
else
rm -f $PIDFILE
Expand All @@ -162,11 +169,12 @@ start() {
OPTIONS="-d -a gcomm://${GALERA_NODES// /,}"
# substitute space with comma for backward compatibility

[ -n "$GALERA_GROUP" ] && OPTIONS="$OPTIONS -g '$GALERA_GROUP'"
[ -n "$GALERA_OPTIONS" ] && OPTIONS="$OPTIONS -o '$GALERA_OPTIONS'"
[ -n "$LOG_FILE" ] && OPTIONS="$OPTIONS -l '$LOG_FILE'"
[ -n "$GALERA_NODE_NAME" ] && OPTIONS="$OPTIONS -n '$GALERA_NODE_NAME'"
[ -n "$GALERA_GROUP" ] && OPTIONS="$OPTIONS -g '$GALERA_GROUP'"
[ -n "$GALERA_OPTIONS" ] && OPTIONS="$OPTIONS -o '$GALERA_OPTIONS'"
[ -n "$LOG_FILE" ] && OPTIONS="$OPTIONS -l '$LOG_FILE'"

eval program_start $OPTIONS
eval program_start "${OPTIONS}"
}

stop() {
Expand Down