56 lines
1.3 KiB
Bash
56 lines
1.3 KiB
Bash
|
#!/bin/bash -eu
|
||
|
# Add wsrep_notify_cmd option
|
||
|
# wsrep_notify_cmd = /usr/bin/wsrep_notify.sh
|
||
|
# Ensure mysql owns the script
|
||
|
# sudo chown mysql:mysql /usr/bin/wsrep_notify.sh
|
||
|
# Also ensure it can be ran
|
||
|
# sudo chmod +x /usr/bin/wsrep_notify.sh
|
||
|
|
||
|
STATUS=""
|
||
|
CLUSTER_UUID=""
|
||
|
PRIMARY=""
|
||
|
INDEX=""
|
||
|
MEMBERS=""
|
||
|
|
||
|
while [ $# -gt 0 ]
|
||
|
do
|
||
|
case $1 in
|
||
|
--status)
|
||
|
STATUS=$2
|
||
|
shift
|
||
|
;;
|
||
|
--uuid)
|
||
|
CLUSTER_UUID=$2
|
||
|
shift
|
||
|
;;
|
||
|
--primary)
|
||
|
[ "$2" = "yes" ] && PRIMARY="1" || PRIMARY="0"
|
||
|
COM=configuration_change
|
||
|
shift
|
||
|
;;
|
||
|
--index)
|
||
|
INDEX=$2
|
||
|
shift
|
||
|
;;
|
||
|
--members)
|
||
|
MEMBERS=$2
|
||
|
shift
|
||
|
;;
|
||
|
esac
|
||
|
shift
|
||
|
done
|
||
|
|
||
|
# I hate bash, I suck at it and I don't want to be good
|
||
|
PAYLOAD="{\\\"status\\\": \\\"${STATUS}\\\", \\\"uuid\\\": \\\"$CLUSTER_UUID\\\", \\\"primary\\\": \\\"$PRIMARY\\\", \\\"index\\\": \\\"$INDEX\\\", \\\"members\\\": \\\"$MEMBERS\\\"}"
|
||
|
|
||
|
DATA='{
|
||
|
"routing_key": "",
|
||
|
"payload_encoding": "string",
|
||
|
"properties": {},'
|
||
|
DATA+="\"payload\": \"$PAYLOAD\" }"
|
||
|
|
||
|
curl --location '[INSERT LOCATION HERE]' \
|
||
|
--header 'Content-Type: application/json' \
|
||
|
--header 'Authorization: [INSERT AUTH TOKEN]' \
|
||
|
--data "$DATA" \
|
||
|
-s
|