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