Update nodemgmt-scripts.sh
This commit is contained in:
@@ -27,7 +27,7 @@ CHECK_DOCKER_SERVICES(){
|
||||
nid=1
|
||||
|
||||
for nip in "${!hosts}"; do
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost'
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost'
|
||||
else NCMD="ssh root@${nip}"; LH=''
|
||||
fi
|
||||
if [ "${NCMD}" != "" ]; then
|
||||
@@ -138,7 +138,7 @@ SET-PERMISSIONS(){
|
||||
if [ "${1}" = "gitea" ]; then
|
||||
nid=1
|
||||
for nip in "${WEB_HOSTS[@]}"; do
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
NCMD=''
|
||||
else
|
||||
NCMD="ssh root@${nip}"
|
||||
@@ -163,7 +163,7 @@ SET-PERMISSIONS(){
|
||||
elif [ "${1}" = "pdnsadmin" ]; then
|
||||
nid=1
|
||||
for nip in "${WEB_HOSTS[@]}"; do
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
NCMD=''
|
||||
else
|
||||
NCMD="ssh root@${nip}"
|
||||
@@ -185,7 +185,7 @@ SET-PERMISSIONS(){
|
||||
done
|
||||
elif [ "${1}" = "nextcloud" ]; then
|
||||
nip=${NC_HOSTS[0]}
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
NCMD=''
|
||||
else
|
||||
NCMD="ssh root@${nip}"
|
||||
@@ -215,7 +215,7 @@ SET-PERMISSIONS(){
|
||||
for nip in "${MYSQL_HOSTS[@]}"; do
|
||||
checkhost=$(CHECK_HOST ${nip})
|
||||
if [ "${checkhost}" != "false" ]; then
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost '
|
||||
NCMD=''
|
||||
else
|
||||
@@ -235,7 +235,7 @@ SET-PERMISSIONS(){
|
||||
for nip in "${WEB_HOSTS[@]}"; do
|
||||
checkhost=$(CHECK_HOST ${nip})
|
||||
if [ "${checkhost}" != "false" ]; then
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost '
|
||||
NCMD=''
|
||||
else
|
||||
@@ -366,7 +366,7 @@ SERVICE(){
|
||||
if [ "$1" = "glusterd" ]; then
|
||||
|
||||
for nip in "${GL_HOSTS[@]}"; do
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost '
|
||||
NCMD=''
|
||||
else
|
||||
@@ -402,7 +402,7 @@ SERVICE(){
|
||||
sleep 5s
|
||||
|
||||
for nip in "${GL_HOSTS[@]}"; do
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost '
|
||||
NCMD=''
|
||||
else
|
||||
@@ -450,11 +450,11 @@ SERVICE(){
|
||||
|
||||
else
|
||||
if [ "${4}" != "all" ]; then
|
||||
IP=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
|
||||
IP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
|
||||
for NTYPE in "${NODE_TYPES[@]}"; do
|
||||
var=${NTYPE}_HOSTS[@]
|
||||
for nip in "${!var}"; do
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
NODE_TYPE=${NTYPE};
|
||||
break 2
|
||||
fi
|
||||
@@ -516,7 +516,7 @@ SERVICE(){
|
||||
if [ "${3}" != "q" ]; then
|
||||
echo -en "${idsCL[LightYellow]}Verifying nginx config and ssl cert replication across the nodes... ${idsCL[Default]}"
|
||||
fi
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${!NT_HOST}"* ]]; then
|
||||
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
|
||||
PH_CMD="ssh root@localhost"
|
||||
else
|
||||
PH_CMD="ssh root@${!NT_HOST}"
|
||||
@@ -550,7 +550,7 @@ SERVICE(){
|
||||
if [ "${3}" != "q" ]; then
|
||||
echo -en "${idsCL[LightYellow]}Verifying Apache config and ssl cert replication across the nodes... ${idsCL[Default]}"
|
||||
fi
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${!NT_HOST}"* ]]; then
|
||||
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
|
||||
PH_CMD="ssh root@localhost"
|
||||
else
|
||||
PH_CMD="ssh root@${!NT_HOST}"
|
||||
@@ -594,7 +594,7 @@ SERVICE(){
|
||||
fi
|
||||
|
||||
for nip in "${var2[@]}"; do
|
||||
# if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${3}"* ]]; then GO=true;
|
||||
# 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;
|
||||
# elif [ ! -z ${3+x} ] || [ "${3}" == "q" ]; then GO=true;
|
||||
# else GO=false;
|
||||
# fi
|
||||
@@ -604,7 +604,7 @@ SERVICE(){
|
||||
else
|
||||
nodename="${NM_NODETYPES[$NTYPE]}-Node${nid}"
|
||||
fi
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost '
|
||||
NCMD=''
|
||||
else
|
||||
@@ -614,7 +614,7 @@ SERVICE(){
|
||||
NOGOCHK=true;
|
||||
# if [ "${1}" == "gitea" ] || [ "${1}" == "pdnsadmin" ] || [ "${1}" == "pdnsadmin.socket" ]; then
|
||||
if [ "${1}" == "gitea" ]; then
|
||||
if [[ $($NCMD /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *10.10.1.120* ]]; then
|
||||
if [[ $($NCMD ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) != *10.10.1.120* ]]; then
|
||||
NOGOCHK=false;
|
||||
fi
|
||||
fi
|
||||
@@ -664,7 +664,7 @@ HAPROXY-CONFIG() {
|
||||
if [[ "${MYSQLSERVICES_CHECK}" = *"haproxy"* ]]; then
|
||||
nid=1
|
||||
for nip in "${MYSQL_HOSTS[@]}"; do
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost '
|
||||
NCMD=''
|
||||
else
|
||||
@@ -684,7 +684,7 @@ HAPROXY-CONFIG() {
|
||||
if [[ "${WEBSERVICES_CHECK}" = *"haproxy"* ]]; then
|
||||
nid=1
|
||||
for nip in "${WEB_HOSTS[@]}"; do
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost '
|
||||
NCMD=''
|
||||
else
|
||||
@@ -703,7 +703,7 @@ HAPROXY-CONFIG() {
|
||||
if [[ "${LBSERVICES_CHECK}" = *"haproxy"* ]]; then
|
||||
nid=1
|
||||
for nip in "${LB_HOSTS[@]}"; do
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost '
|
||||
NCMD=''
|
||||
else
|
||||
@@ -731,7 +731,7 @@ SINGLE_SERVER_SERVICE_CHECK(){
|
||||
servicestocheck=gitea
|
||||
IFS=,; services_to_check=(${servicestocheck}); unset IFS
|
||||
|
||||
local_ips=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1);
|
||||
local_ips=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1);
|
||||
local_ip=$(/sbin/ip -o -4 addr list eth0 |grep 255 | awk '{print $4}' | cut -d/ -f1)
|
||||
if [[ ${local_ips} = *10.10.1.120* ]]; then
|
||||
if [ -f /mnt/web-data/mounted ]; then
|
||||
@@ -778,7 +778,7 @@ KEEPALIVE-CONFIG() {
|
||||
if [[ "${MYSQLSERVICES_CHECK}" = *"keepalive"* ]]; then
|
||||
nid=1
|
||||
for nip in "${MYSQL_HOSTS[@]}"; do
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost '
|
||||
NCMD=''
|
||||
else
|
||||
@@ -798,7 +798,7 @@ KEEPALIVE-CONFIG() {
|
||||
if [[ "${WEBSERVICES_CHECK}" = *"keepalive"* ]]; then
|
||||
nid=1
|
||||
for nip in "${WEB_HOSTS[@]}"; do
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost '
|
||||
NCMD=''
|
||||
else
|
||||
@@ -832,7 +832,7 @@ NODEUPDATE() {
|
||||
echo -e "${idsCL[LightGreen]}Updating All Nodes${idsCL[Default]}"
|
||||
echo -e "${idsCL[LightGreen]}-------------------------------------------${idsCL[Default]}"
|
||||
nip=${MYSQLMANAGER}
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost'
|
||||
fi
|
||||
c=0; cw=14; spca=''
|
||||
@@ -851,7 +851,7 @@ NODEUPDATE() {
|
||||
nid=1
|
||||
var=${NTYPE}_HOSTS[@]
|
||||
for nip in "${!var}"; do
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost '
|
||||
fi
|
||||
NCMD="ssh root@${nip}"
|
||||
@@ -1026,7 +1026,7 @@ RUN_COMMAND(){
|
||||
|
||||
var=${NTYPE}_HOSTS[@]
|
||||
for nip in "${!var}"; do
|
||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost'
|
||||
if [[ $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost'
|
||||
else NCMD="ssh root@${nip}"; LH=''
|
||||
fi
|
||||
echo -e " ${idsST[Bold]}${idsCL[LightCyan]}${NM_NODETYPES[$NTYPE]}-Node${nid} (${nip})${idsST[Reset]}${idsCL[LightCyan]} ${idsCL[LightYello]}${LH}${idsCL[Default]}"
|
||||
|
||||
Reference in New Issue
Block a user