Back (Current repo: terraform-mariadb-replica-homelab)

A terraform homelab with mariadb and maxscale for my own understanding and learning.
To clone this repository:
git clone https://git.viktor1993.net/terraform-mariadb-replica-homelab.git
Log | Download | Files | Refs | README

destroy_maxscale.sh (472B)


#!/bin/bash

BOUNDARY=$1
NUMBER=$2
ROOT_SRC=$3
NEW=$(echo "$BOUNDARY - $NUMBER" | bc)
echo "DELETING SERVERS ${NEW}+ FROM maxscale.cnf"
TMP=$(mktemp)

if [[ $NEW -lt 4 ]]; then
    exit 1
fi

awk -v boundary=$BOUNDARY -v number=$NUMBER -f $ROOT_SRC/awk_scripts/destroy_maxscale.awk /etc/maxscale.cnf > $TMP
cat /etc/maxscale.cnf > /etc/maxscale.cnf.last
cat $TMP > /etc/maxscale.cnf
sed -E -i "s/,server${NEW}.*$//g" /etc/maxscale.cnf

systemctl restart maxscale

rm $TMP