This commit is contained in:
2023-05-14 10:02:48 -05:00
parent 1706dd4a50
commit b8003bee7c
2 changed files with 24 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERS='4.6.50-05132023' VERS='4.6.55-05132023'
# NODETYPES=LB # NODETYPES=LB
NODETYPES=MYSQL,LB,WEB,NC,WPD,LPD,MM,PW NODETYPES=MYSQL,LB,WEB,NC,WPD,LPD,MM,PW

View File

@@ -360,13 +360,16 @@ SERVICES(){
} }
SERVICE(){ SERVICE(){
TSI=$(/sbin/ip link | grep tailscale0)
MIP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
[ ${#TSI} != 0 ] && TSIP=$(/sbin/ip -o -4 addr list tailscale0 | awk '{print $4}' | cut -d/ -f1) || TSIP=""
NODE_TYPE='' NODE_TYPE=''
#var=NC_HOSTS[@] #var=NC_HOSTS[@]
if [ "$1" = "glusterd" ]; then if [ "$1" = "glusterd" ]; then
for nip in "${GL_HOSTS[@]}"; do for nip in "${GL_HOSTS[@]}"; do
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then if [[ "${MIP}" == *"${nip}"* ]]; then
nip='localhost ' nip='localhost '
NCMD='' NCMD=''
else else
@@ -402,7 +405,7 @@ SERVICE(){
sleep 5s sleep 5s
for nip in "${GL_HOSTS[@]}"; do for nip in "${GL_HOSTS[@]}"; do
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then if [[ "${MIP}" == *"${nip}"* ]]; then
nip='localhost ' nip='localhost '
NCMD='' NCMD=''
else else
@@ -450,31 +453,21 @@ SERVICE(){
else else
if [ "${4}" != "all" ]; then if [ "${4}" != "all" ]; then
IP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
echo "IP: ${IP}"
for NTYPE in "${NODE_TYPES[@]}"; do for NTYPE in "${NODE_TYPES[@]}"; do
var=${NTYPE}_HOSTS[@] var=${NTYPE}_HOSTS[@]
NODE_TYPE="" NODE_TYPE=""
for nip in "${!var}"; do for nip in "${!var}"; do
echo "$IP - $nip" if [[ "${MIP}" == *"${nip}"* ]]; then
if [[ "${IP}" == *"${nip}"* ]]; then
NODE_TYPE=${NTYPE}; NODE_TYPE=${NTYPE};
break 2 break 2
fi fi
done done
done done
echo "NODETYPE: ${NODE_TYPE}" if [ "${NODE_TYPE}" == "" ] && [ ${#TSI} != 0 ]; then
if [ "${NODE_TYPE}" == "" ]; then
TSI=$(/sbin/ip link | grep tailscale0)
TSIP=$(/sbin/ip -o -4 addr list tailscale0 | awk '{print $4}' | cut -d/ -f1)
echo "TSIP: ${TSIP}"
if [ ${#TSI} != 0 ]; then
for NTYPE in "${NODE_TYPES[@]}"; do for NTYPE in "${NODE_TYPES[@]}"; do
var=${NTYPE}_HOSTS[@] var=${NTYPE}_HOSTS[@]
for nip in "${!var}"; do for nip in "${!var}"; do
echo "${TSIP} - $nip"
if [[ "${TSIP}" == *"${nip}"* ]]; then if [[ "${TSIP}" == *"${nip}"* ]]; then
NODE_TYPE=${NTYPE}; NODE_TYPE=${NTYPE};
break 2 break 2
@@ -482,9 +475,6 @@ SERVICE(){
done done
done done
fi fi
fi
echo "NODETYPE: ${NODE_TYPE}"
if [ "${NODE_TYPE}" != "" ]; then if [ "${NODE_TYPE}" != "" ]; then
NT_HOSTS=${NODE_TYPE}_HOSTS[@] NT_HOSTS=${NODE_TYPE}_HOSTS[@]
@@ -525,7 +515,7 @@ SERVICE(){
if [ "${3}" != "q" ]; then if [ "${3}" != "q" ]; then
echo -en "${idsCL[LightYellow]}Verifying nginx config and ssl cert replication across the nodes... ${idsCL[Default]}" echo -en "${idsCL[LightYellow]}Verifying nginx config and ssl cert replication across the nodes... ${idsCL[Default]}"
fi fi
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${!NT_HOST}"* ]]; then if [[ "${MIP}" == *"${!NT_HOST}"* ]]; then
PH_CMD="ssh root@localhost" PH_CMD="ssh root@localhost"
else else
PH_CMD="ssh root@${!NT_HOST}" PH_CMD="ssh root@${!NT_HOST}"
@@ -559,7 +549,7 @@ SERVICE(){
if [ "${3}" != "q" ]; then if [ "${3}" != "q" ]; then
echo -en "${idsCL[LightYellow]}Verifying Apache config and ssl cert replication across the nodes... ${idsCL[Default]}" echo -en "${idsCL[LightYellow]}Verifying Apache config and ssl cert replication across the nodes... ${idsCL[Default]}"
fi fi
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${!NT_HOST}"* ]]; then if [[ "${MIP}" == *"${!NT_HOST}"* ]]; then
PH_CMD="ssh root@localhost" PH_CMD="ssh root@localhost"
else else
PH_CMD="ssh root@${!NT_HOST}" PH_CMD="ssh root@${!NT_HOST}"
@@ -603,7 +593,9 @@ SERVICE(){
fi fi
for nip in "${var2[@]}"; do for nip in "${var2[@]}"; do
# if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${3}"* ]]; then GO=true;
# if [[ "${MIP}" == *"${3}"* ]]; then GO=true;
# elif [ ! -z ${3+x} ] || [ "${3}" == "q" ]; then GO=true; # elif [ ! -z ${3+x} ] || [ "${3}" == "q" ]; then GO=true;
# else GO=false; # else GO=false;
# fi # fi
@@ -613,7 +605,7 @@ SERVICE(){
else else
nodename="${NM_NODETYPES[$NTYPE]}-Node${nid}" nodename="${NM_NODETYPES[$NTYPE]}-Node${nid}"
fi fi
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then if [[ "${MIP}" == *"${nip}"* ]]; then
nip='localhost ' nip='localhost '
NCMD='' NCMD=''
else else