This commit is contained in:
2023-06-23 22:33:12 -05:00
parent 61845e5552
commit 30462b0a57
2 changed files with 12 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
VERS='4.7.131-06212023'
VERS='4.7.135-06212023'
# NODETYPES=WEB
NODETYPES=LB,LPD,MM,MYSQL,NC,PW,WPD,WM,WEB
@@ -36,8 +36,9 @@ WMDOCKER=uptime-kuma
PWDOCKER=uptime-kuma
#LBDOCKER=nginx-proxy_manager
SINGLESERVICES=gitea
SINGLEDOCKERS=vaultwarden,heimdall,authelia
WEB_SINGLESRVRSERVICES=gitea
WEB_SINGLESRVRDOCKERS=vaultwarden,heimdall,authelia
WEB_SINGLESRVR_IP=10.10.1.20
LB_NGINX_SITES='/opt/lb-data/nginx/sites-enabled'
WEB_NGINX_SITES='/mnt/web-data/nginx/sites-enabled'
@@ -123,8 +124,8 @@ LB_DOCKER=(${LBDOCKER})
WM_DOCKER=(${WMDOCKER})
PW_DOCKER=(${PWDOCKER})
SINGLE_SERVICES=(${SINGLESERVICES})
SINGLE_DOCKERS=(${SINGLEDOCKERS})
WEB_SINGLESRVR_SERVICES=(${WEB_SINGLESRVRSERVICES})
WEB_SINGLESRVR_DOCKERS=(${WEB_SINGLESRVRDOCKERS})
unset IFS

View File

@@ -727,9 +727,7 @@ HAPROXY-CONFIG() {
}
SINGLE_SERVER_SERVICE_CHECK(){
if [ "${1}" = "web" ]; then
# servicestocheck=gitea,pdnsadmin
if [ "${1}" = "web" ]; then
local_ips=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | awk '/inet/ {print $2}' | 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)
@@ -739,8 +737,7 @@ SINGLE_SERVER_SERVICE_CHECK(){
sleep 5s
fi
if [ -f /mnt/web-data/mounted ]; then
for stc in "${SINGLE_SERVICES[@]}"; do
echo "SERVICE: $stc"
for stc in "${WEB_SINGLESRVR_SERVICES[@]}"; do
if [ "$(systemctl is-active ${stc}.service)" != "active" ]; then
SENDNOTICE "Node-Balancing Notice" "Starting ${stc} on ${NM_NODETYPES["WEB"]}-Node${local_ip: -1} (${local_ip}), stopping on the other Nodes"
echo "$(date) - ${NM_NODETYPES["WEB"]}-Node${local_ip: -1} - Starting ${stc} on ${local_ip}, stopping on the other Nodes" >> ${LOGFILE}
@@ -755,8 +752,7 @@ SINGLE_SERVER_SERVICE_CHECK(){
/bin/systemctl start ${stc} &
fi
done
for docker in "${SINGLE_DOCKERS[@]}"; do
echo "DOCKER: $docker"
for docker in "${WEB_SINGLESRVR_DOCKERS[@]}"; do
for nip in "${WEB_HOSTS[@]}"; do
if [[ "${local_ip}" = *"${nip}"* ]]; then
[ ! "$(/usr/bin/docker ps -q -f name=${docker})" ] && /usr/bin/docker start ${docker} & >/dev/null 2>&1
@@ -773,11 +769,11 @@ SINGLE_SERVER_SERVICE_CHECK(){
else
for stc in "${services_to_check[@]}"; do
for stc in "${WEB_SINGLESRVR_SERVICES[@]}"; do
[ "${stc}" = "pdnsadmin" ] && stc="pdnsadmin.socket pdnsadmin.service"
/bin/systemctl stop ${stc} &
done
for docker in "${SINGLE_DOCKERS[@]}"; do
for docker in "${WEB_SINGLESRVR_DOCKERS[@]}"; do
# echo "DOCKER: $docker"
[ "$(/usr/bin/docker ps -q -f name=${docker})" ] && /usr/bin/docker stop ${docker} & >/dev/null 2>&1
# [ "$(/usr/bin/docker ps -q -f name=${docker})" ] && echo "stopping" || echo "already stopped"
@@ -785,7 +781,7 @@ SINGLE_SERVER_SERVICE_CHECK(){
fi
if [ "$(systemctl is-active nginx)" != "active" ]; then
/usr/local/bin/nodemgmt service web restart ${local_ip}
${SCRIPT} service web restart ${local_ip}
fi
fi
}