This commit is contained in:
2019-03-06 13:01:18 -06:00
parent 0df9d4aa70
commit 106e14bfef
3 changed files with 37 additions and 34 deletions

View File

@@ -2,11 +2,11 @@
VERS='3.03032019'
NODEHOSTS=10.5.10.51,10.5.10.52,10.5.10.53
WEBHOSTS=10.5.10.120,10.5.10.121
WEBHOSTS=10.5.10.121,10.5.10.122,10.5.10.123
PRIMARYHOST=10.5.10.51
NODESERVICES=mysql,nginx,gitea,powerdns-admin,haproxy,keepalived,maxscale,postgresql
NODESERVICES_CHECK=mysql,haproxy,keepalived,maxscale
WEBSERVICES_CHECK=nginx,gitea,haproxy,keepalived
WEBSERVICES_CHECK=nginx,gitea
noheader=' service status-check nightlyrenew backup report check checkcerts gitea '
CERT_DAEMON='/usr/bin/certbot'
FOLDER=/opt/idssys/nodemgmt

View File

@@ -77,7 +77,7 @@ STATUS(){
fi
if [ ! -z ${LOCAL_SERVICES+x} ]; then
if [ "${ST_ACTION}" != "check" ]; then
lip=$(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1)
lip=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
uptime=`uptime -p`
echo -e " ${idsST[Bold]}${idsCL[LightCyan]}${NODE_HOSTNAME} (${lip})${idsST[Reset]}${idsCL[LightCyan]} - ${uptime} - localhost${idsCL[Default]}"
DIVIDER false green
@@ -133,7 +133,7 @@ STATUS(){
########################
nid=1
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost'
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost'
else NCMD="ssh root@${nip}"; LH=''
fi
if [ "${ST_ACTION}" != "check" ]; then
@@ -223,7 +223,7 @@ STATUS(){
########################
nid=1
for nip in "${WEB_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost'
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost'
else NCMD="ssh root@${nip}"; LH=''
fi
if [ "${ST_ACTION}" != "check" ]; then
@@ -321,7 +321,7 @@ STATUS(){
nid=1
for nip in "${NODE_HOSTS[@]}"; do
if [ "${nip}" = "${NODE_HOSTS[0]}" ] && [ ! -z ${LOCAL_SERVICES+x} ]; then isreplhost=true; else isreplhost=false; fi
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]] && [ "${isreplhost}" = "false" ]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]] && [ "${isreplhost}" = "false" ]; then
if [ "${ST_ACTION}" != "check" ]; then
echo -e " ${idsCL[LightCyan]}iDS-MySQL1 (${NODE_HOSTS[0]}) <--> ${idsST[Bold]}iDS-MySQL${nid} (${nip})${idsST[Reset]}${idsCL[Default]}"
DIVIDER false green
@@ -387,7 +387,7 @@ STATUS(){
nid=1
for nip in "${WEB_HOSTS[@]}"; do
if [ "${nip}" = "${WEB_HOSTS[0]}" ] && [ ! -z ${LOCAL_SERVICES+x} ]; then isreplhost=true; else isreplhost=false; fi
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]] && [ "${isreplhost}" = "false" ]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]] && [ "${isreplhost}" = "false" ]; then
if [ "${ST_ACTION}" != "check" ]; then
echo -e " ${idsCL[LightCyan]}iDS-Webserver1 (${WEB_HOSTS[0]}) <--> ${idsST[Bold]}iDS-Webserver${nid} (${nip})${idsST[Reset]}${idsCL[Default]}"
DIVIDER false green
@@ -484,7 +484,7 @@ NEWCERT(){
echo ""
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]]; then
`ssh root@${nip} service nginx stop`
fi
done
@@ -507,7 +507,7 @@ NEWCERT(){
until [ "${checked}" = "" ]; do
tchecked=''
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''
else NCMD="ssh root@${nip}"
fi
if [ "${NCMD}" != "" ]; then
@@ -534,7 +534,7 @@ NEWCERT(){
echo -e "${idsCL[Red]}Certificate could not be created for '${idsCL[Yellow]}${NEW_CERT}${idsCL[Red]}'...${idsCL[Default]}"
fi
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]]; then
`ssh root@${nip} service nginx start`
fi
done
@@ -576,7 +576,7 @@ DEL-SSL(){
until [ "${checked}" = "" ]; do
tchecked=''
for nip in "${WEB_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''
else NCMD="ssh root@${nip}"
fi
if [ "${NCMD}" != "" ]; then
@@ -623,7 +623,7 @@ CERTRENEW(){
until [ "${checked}" = "" ]; do
tchecked=''
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''
else NCMD="ssh root@${nip}"
fi
if [ "${NCMD}" != "" ]; then
@@ -662,7 +662,7 @@ NIGHTLYRENEW(){
until [ "${checked}" = "" ]; do
tchecked=''
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''
else NCMD="ssh root@${nip}"
fi
if [ "${NCMD}" != "" ]; then
@@ -836,7 +836,7 @@ DELSITE(){
nid=1
for nip in "${WEB_HOSTS[@]}"
do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
nip='localhost '
NCMD=''
else
@@ -1075,7 +1075,7 @@ NEWSITE(){
echo -e "}" >> /etc/nginx/sites-available/${MAIN_SITE}
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''
else NCMD="ssh root@${nip}"
fi
${NCMD} mkdir -p /var/www/${MAIN_SITE}/{public_html,nginx_logs}
@@ -1133,7 +1133,7 @@ NEWSITE(){
until [ "${checked}" = "" ]; do
tchecked=''
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''
else NCMD="ssh root@${nip}"
fi
if [ "${NCMD}" != "" ]; then
@@ -1174,7 +1174,7 @@ NEWSITE(){
SET-PERMISSIONS(){
if [ "${1}" = "gitea" ]; then
for nip in "${WEB_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
NCMD=''
else
NCMD="ssh root@${nip}"
@@ -1188,11 +1188,11 @@ SET-PERMISSIONS(){
NEW_SITE=${1}
echo -e "${idsCL[Yellow]}Setting new site folder permissions for (/var/www/${NEW_SITE})${idsCL[Default]}"
fi
if [ "${NEW_SITE}" = "" ]; then
if [ "${NEW_SITE}" = "xxx" ]; then
nid=1
for nip in "${NODE_HOSTS[@]}"
do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
nip='localhost '
NCMD=''
else
@@ -1210,7 +1210,7 @@ SET-PERMISSIONS(){
nid=1
for nip in "${WEB_HOSTS[@]}"
do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
nip='localhost '
NCMD=''
else
@@ -1349,7 +1349,7 @@ SERVICE(){
nid=1
if [[ "${NODESERVICES_CHECK}" = *"${1}"* ]]; then
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
nip='localhost '
NCMD=''
else
@@ -1378,7 +1378,7 @@ SERVICE(){
nid=1
if [[ "${WEBSERVICES_CHECK}" = *"${1}"* ]]; then
for nip in "${WEB_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
nip='localhost '
NCMD=''
else
@@ -1410,7 +1410,7 @@ HAPROXY-CONFIG() {
if [[ "${NODESERVICES_CHECK}" = *"haproxy"* ]]; then
nid=1
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
nip='localhost '
NCMD=''
else
@@ -1430,7 +1430,7 @@ HAPROXY-CONFIG() {
if [[ "${WEBSERVICES_CHECK}" = *"haproxy"* ]]; then
nid=1
for nip in "${WEB_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
nip='localhost '
NCMD=''
else
@@ -1458,7 +1458,7 @@ KEEPALIVE-CONFIG() {
if [[ "${NODESERVICES_CHECK}" = *"keepalive"* ]]; then
nid=1
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
nip='localhost '
NCMD=''
else
@@ -1478,7 +1478,7 @@ KEEPALIVE-CONFIG() {
if [[ "${WEBSERVICES_CHECK}" = *"keepalive"* ]]; then
nid=1
for nip in "${WEB_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
nip='localhost '
NCMD=''
else
@@ -1505,7 +1505,7 @@ NODEUPDATE() {
echo -e "${idsCL[LightGreen]}-------------------------------------------${idsCL[Default]}"
nid=1
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
nip='localhost '
NCMD=''
else
@@ -1519,7 +1519,7 @@ NODEUPDATE() {
echo
nid=1
for nip in "${WEB_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
nip='localhost '
NCMD=''
else

View File

@@ -83,8 +83,9 @@ listen NGINX_http
# option allbackups
default-server port 9200 inter 2s downinter 5s rise 3 fall 2 slowstart 60s maxconn 64 maxqueue 128 weight 100
cookie SERVERUSED insert indirect nocache
server 10.5.10.120 10.5.10.120:80 cookie s1 check port 80
server 10.5.10.121 10.5.10.121:80 cookie s2 check port 80
server 10.5.10.121 10.5.10.121:80 cookie s1 check port 80
server 10.5.10.122 10.5.10.122:80 cookie s2 check port 80
server 10.5.10.123 10.5.10.123:80 cookie s3 check port 80 backup
listen NGINX_https
bind *:443
@@ -97,8 +98,9 @@ listen NGINX_https
# option allbackups
default-server port 9200 inter 2s downinter 5s rise 3 fall 2 slowstart 60s maxconn 64 maxqueue 128 weight 100
cookie SERVERUSED insert indirect nocache
server 10.5.10.120 10.5.10.120:443 cookie s1 check port 443
server 10.5.10.121 10.5.10.121:443 cookie s2 check port 443
server 10.5.10.121 10.5.10.121:443 cookie s1 check port 443
server 10.5.10.122 10.5.10.122:443 cookie s2 check port 443
server 10.5.10.123 10.5.10.123:443 cookie s3 check port 443 backup
listen Gitea
bind *:3000
@@ -111,5 +113,6 @@ listen Gitea
# option allbackups
default-server port 9200 inter 2s downinter 5s rise 3 fall 2 slowstart 60s maxconn 64 maxqueue 128 weight 100
cookie SERVERUSED insert indirect nocache
server 10.5.10.120 10.5.10.120:3000 cookie s1 check port 3000
server 10.5.10.121 10.5.10.121:3000 cookie s2 check port 3000 backup
server 10.5.10.121 10.5.10.121:3000 cookie s1 check port 3000
server 10.5.10.122 10.5.10.122:3000 cookie s2 check port 3000 backup
server 10.5.10.123 10.5.10.123:3000 cookie s3 check port 3000 backup