Fix for multinode

This commit is contained in:
Micke Nordin 2023-03-24 14:36:07 +01:00
parent 6de5312e7c
commit 8386df91de
Signed by untrusted user: Micke
GPG key ID: 0DA0A7A5708FE257

View file

@ -1,8 +1,14 @@
#!/bin/bash
PATH="${PATH}:/usr/local/bin"
restarted="false"
domain=$(hostname -d)
prefix="intern-db"
if [[ ${domain} =~ ^drive ]]; then
prefix="multinode-db"
fi
for index in 1 2 3; do
db_ip=$(host "intern-db${index}.$(hostname -d)" | awk '/has address/ {print $NF}')
db_ip=$(host "${prefix}${index}.${domain}" | awk '/has address/ {print $NF}')
result=$(proxysql "select * from main.mysql_servers where hostname = '${db_ip}' and hostgroup_id = 10")
if [[ -z ${result} ]]; then
query="INSERT INTO main.mysql_servers (hostgroup_id, hostname, max_connections, comment) VALUES( 10, '${db_ip}', 100, 'Inserted by script at $(date)')"