Update services.inc
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
SINGLE_SERVER_SERVICE_CHECK(){
|
SINGLE_SERVER_SERVICE_CHECK(){
|
||||||
servicestocheck=${1^^}_SINGLESRVR_SERVICES[@]
|
servicestocheck=${1^^}_SINGLESRVR_SERVICES[@]
|
||||||
dockerstocheck=${1^^}_SINGLESRVR_DOCKERS[@]
|
dockerstocheck=${1^^}_SINGLESRVR_DOCKERS[@]
|
||||||
@@ -8,6 +9,10 @@ SINGLE_SERVER_SERVICE_CHECK(){
|
|||||||
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" | 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 ${NM_TMPFOLDER}/.singleserver ]; then
|
||||||
|
SENDNOTICE "Node-Balancing Notice" "Starting SingleServer Services on ${NM_NODETYPES["WEB"]}-Node${local_ip: -1} (${local_ip}), stopping on other Nodes"
|
||||||
|
touch ${NM_TMPFOLDER}/.singleserver
|
||||||
|
fi
|
||||||
if [ ! -f /mnt/web-data/mounted ]; then
|
if [ ! -f /mnt/web-data/mounted ]; then
|
||||||
/bin/mount -a
|
/bin/mount -a
|
||||||
sleep 5s
|
sleep 5s
|
||||||
@@ -15,13 +20,13 @@ SINGLE_SERVER_SERVICE_CHECK(){
|
|||||||
if [ -f ${NM_REPL_CHECK_LOC["${1}-data"]}/mounted ]; then
|
if [ -f ${NM_REPL_CHECK_LOC["${1}-data"]}/mounted ]; then
|
||||||
for stc in "${!servicestocheck}"; do
|
for stc in "${!servicestocheck}"; do
|
||||||
if [ "$(systemctl is-active ${stc}.service)" != "active" ]; then
|
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" >> ${NM_LOGFILE}
|
echo "$(date) - ${NM_NODETYPES["WEB"]}-Node${local_ip: -1} - Starting ${stc} on ${local_ip}, stopping on the other Nodes" >> ${NM_LOGFILE}
|
||||||
|
|
||||||
[ "${stc}" = "pdnsadmin" ] && stc="pdnsadmin.socket pdnsadmin.service"
|
[ "${stc}" = "pdnsadmin" ] && stc="pdnsadmin.socket pdnsadmin.service"
|
||||||
for nip in "${!hosts}"; do
|
for nip in "${!hosts}"; do
|
||||||
if [[ "${local_ip}" != *"${nip}"* ]]; then
|
if [[ "${local_ip}" != *"${nip}"* ]]; then
|
||||||
ssh root@${nip} /bin/systemctl stop ${stc}
|
ssh -tq root@${nip} /bin/systemctl stop ${stc}
|
||||||
|
ssh -tq root@${nip} rm -f ${NM_TMPFOLDER}/.singleserver
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
sleep 3s
|
sleep 3s
|
||||||
|
|||||||
Reference in New Issue
Block a user