This commit is contained in:
2019-03-08 01:07:25 -06:00
parent 4729ecf20d
commit a241f5c84b
2 changed files with 49 additions and 4 deletions

View File

@@ -3,12 +3,12 @@
VERS='3.03032019'
NODEHOSTS=10.5.10.51,10.5.10.52,10.5.10.53
WEBHOSTS=10.5.10.121,10.5.10.122,10.5.10.123
#WEBHOSTS=10.10.10.81,10.10.10.82,10.10.10.83
LBHOSTS=
LBHOSTS=10.10.10.81,10.10.10.82,10.10.10.83
PRIMARYHOST=10.5.10.51
NODESERVICES=mysql,nginx,gitea,powerdns-admin,haproxy,keepalived,maxscale,postgresql
NODESERVICES_CHECK=mysql
WEBSERVICES_CHECK=nginx,gitea
LBSERVICES_CHECK=haproxy,keepalived
noheader=' service status-check nightlyrenew backup report check checkcerts gitea '
CERT_DAEMON='/usr/bin/certbot'
FOLDER=/opt/idssys/nodemgmt
@@ -20,9 +20,11 @@ declare -i errtime
IFS=,
NODE_HOSTS=(${NODEHOSTS})
WEB_HOSTS=(${WEBHOSTS})
LB_HOSTS=(${LBHOSTS})
NODE_SERVICES=(${NODESERVICES})
NODE_SERVICES_CHECK=(${NODESERVICES_CHECK})
WEB_SERVICES_CHECK=(${WEBSERVICES_CHECK})
LB_SERVICES_CHECK=(${LBSERVICES_CHECK})
LOCAL_SERVICES=(${LOCAL_SERVICES})
unset IFS
@@ -62,6 +64,7 @@ REPL_CHECKS['gitssh']='/home/git'
NODE_REPL_CHECK=( )
WEB_REPL_CHECK=(nginx ssl php www git gitssh)
LB_REPL_CHECK=( )
declare -A REPL_DESC
REPL_DESC['nginx']='NGINX Settings'

View File

@@ -1349,8 +1349,8 @@ SERVICE(){
echo -e "${idsCL[LightGreen]}[[${NM_SERVICES[${1}]} ${NM_SRVCOPTS[${2}]}ing]]${idsCL[Default]}"
echo -e "${idsCL[LightGreen]}-------------------------------------------${idsCL[Default]}"
nid=1
if [[ "${NODESERVICES_CHECK}" = *"${1}"* ]]; then
nid=1
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
nip='localhost '
@@ -1378,8 +1378,8 @@ SERVICE(){
nid=`expr $nid + 1`
done
fi
nid=1
if [[ "${WEBSERVICES_CHECK}" = *"${1}"* ]]; 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
nip='localhost '
@@ -1401,6 +1401,29 @@ SERVICE(){
nid=`expr $nid + 1`
done
fi
if [[ "${LBSERVICES_CHECK}" = *"${1}"* ]]; 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
nip='localhost '
NCMD=''
else
NCMD="ssh root@${nip}"
fi
echo -en "${NM_SRVCOPTS[${2}]}ing on LB-Node${nid} ($nip)... ${idsCL[Default]}"
$NCMD systemctl $2 $1
if [[ "enable,disable" = *"${2}"* ]] || [ "${1}" = "daemon-reload" ]; then
echo -e "${idsCL[Green]}OK${idsCL[Default]}"
elif [ "$(${NCMD} systemctl is-active ${1})" = "active" ]; then
echo -e "${idsCL[Green]}OK${idsCL[Default]}"
elif [ "$2" = "stop" ]; then
echo -e "${idsCL[Red]}STOPPED${idsCL[Default]}"
else
echo -e "${idsCL[Red]}ERROR${idsCL[Default]}"
fi
nid=`expr $nid + 1`
done
fi
echo ""
echo -e "${idsCL[Green]}${NM_SERVICES[${1}]} has been ${NM_SRVCOPTS[${2}]}ed${idsCL[Default]}"
@@ -1449,6 +1472,25 @@ HAPROXY-CONFIG() {
nid=`expr $nid + 1`
done
fi
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
nip='localhost '
NCMD=''
else
NCMD="ssh root@${nip}"
fi
echo -en "Creating File on LB-Node${nid} ($nip)... ${idsCL[Default]}"
${NCMD} "nodemgmt update q"
${NCMD} "rm -f /etc/haproxy/haproxy.cfg"
${NCMD} "sed -e 's;%NIP%;${nip};g' ${FOLDER}/templates/haproxy.config > /etc/haproxy/haproxy.cfg"
echo -e "${idsCL[Green]}COMPLETE${idsCL[Default]}"
nid=`expr $nid + 1`
done
fi
SERVICE haproxy reload
echo ""
echo -e "${idsCL[Green]}HAProxy Config Files have been created.${idsCL[Default]}"