script shellchecked
This commit is contained in:
@@ -1,14 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-nopassword}
|
||||||
|
|
||||||
# slave not configured
|
# slave not configured
|
||||||
RES=$(mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -e 'SHOW SLAVE STATUS\G')
|
SLAVE_STATUS=$(mysql -uroot -p"${MYSQL_ROOT_PASSWORD}" -e 'SHOW SLAVE STATUS\G')
|
||||||
if [ "a$RES" = "a" ]; then
|
if [[ -z "${SLAVE_STATUS}" ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# extract slave status
|
||||||
|
SLAVE_IO=$(echo "${SLAVE_STATUS}" | awk -F: '/Slave_IO_Running/ {gsub(/ /, "", $2); print $2}')
|
||||||
|
SLAVE_SQL=$(echo "${SLAVE_STATUS}" | awk -F: '/Slave_SQL_Running/ {gsub(/ /, "", $2); print $2}')
|
||||||
|
|
||||||
# slave ok
|
# slave ok
|
||||||
RES=$(mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -e 'SHOW SLAVE STATUS\G' | egrep '(Slave_IO_Running|Slave_SQL_Running):' | awk -F: '{print $2}' | tr '\n' ',')
|
if [[ "${SLAVE_IO}" == "Yes" && "${SLAVE_SQL}" == "Yes" ]]; then
|
||||||
if [ "$RES" = " Yes, Yes," ]; then
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user