From 3ad3836cd6355f837f7e34402631a249ef41155c Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Mon, 13 Nov 2023 09:17:41 -0600 Subject: [PATCH] update --- defaults.inc | 2 +- inc/certs.inc | 48 ++++++++---------------------------------------- inc/sites.inc | 2 +- inc/status.inc | 20 ++++++++++---------- 4 files changed, 20 insertions(+), 52 deletions(-) diff --git a/defaults.inc b/defaults.inc index d094a7d3..8f161788 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERS='4.13.25-11122023' +VERS='4.13.27-11132023' noheader=' service status-check nightlyrephp7.3-fpm,new backup report check checkcerts gitea update-nodes copynpmcerts singleservercheck update-dyndns backup-offsitepfsense gui nightlyreview update ' CERT_DAEMON='/snap/bin/certbot' diff --git a/inc/certs.inc b/inc/certs.inc index 035e3199..d63d86b5 100755 --- a/inc/certs.inc +++ b/inc/certs.inc @@ -196,30 +196,6 @@ LISTCERTS(){ unset IFS fi - for ccc in ${!CHECKCERT_DOMAINS[@]}; do - echo "HERE1: ${ccc} = ${CHECKCERT_DOMAINS[${ccc}]}" - done - - - - # declare -A oldCHECKCERT_DOMAINS - # IFS=$'\n' - # for LINE in `egrep -v '(^#|^$)' ${NM_FOLDER}/conf/ssl-domain-checks.conf`; do - # HOST=${LINE%% *} - # PORT=${LINE#* } - # IFS=" " - # oldCHECKCERT_DOMAINS+="${HOST} ${PORT}" - # done - # unset IFS - # echo - IFS=$'\n' CHECKCERT_DOMAINSnew=($(sort <<<"$(cat ${NM_FOLDER}/conf/ssl-domain-checks.conf)")) - unset IFS - for ccc in ${CHECKCERT_DOMAINSnew[@]}; do - echo "HERE2: ${ccc}" - done - - - # if [ ! -z ${LOCAL_SERVICES+x} ]; then # NCMD="ssh root@${NM_HOSTS['LB'][0]}" # #${NCMD} rm -f /tmp/ssllist @@ -418,23 +394,15 @@ LISTCERTS(){ if [ "${monitored^^}" == "YES" ]; then if [ "$(grep ${SUBJECT} ${NM_FOLDER}/conf/ssl-domain-checks.conf)" == "" ]; then [ ! -f ${NM_FOLDER}/conf/ssl-domain-checks.conf ] && touch ${NM_FOLDER}/conf/ssl-domain-checks.conf - # echo "${SUBJECT} 443" >> ${NM_FOLDER}/conf/ssl-domain-checks.conf - - unset CHECKCERT_DOMAINS - declare -A CHECKCERT_DOMAINS - IFS=$'\n' - for LINE in `egrep -v '(^#|^$)' ${NM_FOLDER}/conf/ssl-domain-checks.conf`; do - HOST=${LINE%% *} - PORT=${LINE#* } - IFS=" " - oldCHECKCERT_DOMAINS[${HOST}]=${PORT} - done - unset IFS - readarray -td '' CHECKCERT_DOMAINS < <(printf '%s\0' "${oldCHECKCERT_DOMAINS[@]}" | sort -z) + echo "${SUBJECT} 443" >> ${NM_FOLDER}/conf/ssl-domain-checks.conf >/dev/null 2&>1 + checkcerts_sorted=$(sort <<< "$(cat ${NM_FOLDER}/conf/ssl-domain-checks.conf)") + if [ "${NM_NODEMANAGER}" != "$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1 | head -n1)" ]; then + ssh root@${NM_NODEMANAGER} rm -f ${NM_FOLDER}/conf/ssl-domain-checks.conf >/dev/null 2&>1 + ssh root@${NM_NODEMANAGER} echo "${checkcerts_sorted}" > ${NM_FOLDER}/conf/ssl-domain-checks.conf >/dev/null 2&>1 + fi + rm -f ${NM_FOLDER}/conf/ssl-domain-checks.conf >/dev/null 2&>1 + echo "${checkcerts_sorted}" > ${NM_FOLDER}/conf/ssl-domain-checks.conf >/dev/null 2&>1 fi - - - else sed -i "/${SUBJECT}/d" ${NM_FOLDER}/conf/ssl-domain-checks.conf fi diff --git a/inc/sites.inc b/inc/sites.inc index 7a90d26b..a4d25d9b 100755 --- a/inc/sites.inc +++ b/inc/sites.inc @@ -634,7 +634,7 @@ SITEINFO(){ done if [ "${onefacline}" == "" ]; then - [ "$($NCMD /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)" != "${NM_AUTHELIA_IP}" ] && ACMD="ssh root@${NM_AUTHELIA_IP}" || ACMD="" + [ "$($NCMD /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1 | head -n1)" != "${NM_AUTHELIA_IP}" ] && ACMD="ssh root@${NM_AUTHELIA_IP}" || ACMD="" autheliaconfig=$(${ACMD} cat ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml) onefacline=$(echo "${autheliaconfig}" | grep -Fn one_factor | sort | tail -n1) onefacline=${onefacline%%:*} diff --git a/inc/status.inc b/inc/status.inc index c00e7624..a6743351 100755 --- a/inc/status.inc +++ b/inc/status.inc @@ -40,7 +40,7 @@ STATUS(){ if [ "${ST_ACTION}" = "" ] || [ "${ST_ACTION}" = "report" ] || [ "${ST_ACTION}" = "services" ] || [ "${ST_ACTION}" = "dockers" ] || [ "${ST_ACTION}" = "check" ]; then if [ ! -z ${LOCAL_SERVICES+x} ] && [ "${ST_ACTION}" != "dockers" ]; then if [ "${ST_ACTION}" != "check" ]; then - lip=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) + lip=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1 | head -n1) echo -e "\n$(DIVIDER)\n${idsCL[Yellow]}${idsST[Bold]} LOCALHOST Service Status${idsST[Reset]}${idsCL[Default]}" echo -e "$(DIVIDER)\n" echo -en " ${idsST[Bold]}${idsCL[LightCyan]}${NODE_HOSTNAME} (${lip})${idsST[Reset]}" @@ -53,7 +53,7 @@ STATUS(){ DIVIDER . green fi # if [ "${ST_ACTION}" != "check" ]; then - # lip=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) + # lip=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1 | head -n1) # uptime=`uptime -p` # echo -e " ${idsST[Bold]}${idsCL[LightCyan]}${NODE_HOSTNAME} (${lip})${idsST[Reset]}${idsCL[LightCyan]} - ${uptime} - localhost${idsCL[Default]}" # DIVIDER false green @@ -141,7 +141,7 @@ STATUS(){ for nip in "${!var}"; do [ "${ST_ACTION}" != "check" ] && echo -en " ${idsST[Bold]}${idsCL[LightCyan]}${NM_HOSTNAMES[${nip}]} [${nip}]${idsST[Reset]}" - if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then + if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1 | head -n1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost' else NCMD="ssh root@${nip}"; LH='' @@ -188,8 +188,8 @@ STATUS(){ [ "${NTYPE}" != "OFW" ] && srvctst=(`${NCMD} "systemctl is-active ${srvcstotest}"`) sr=0 for srvc in "${!srvcs}"; do - [ "${srvc}" == "gitea" ] && [ "${NTYPE}" == "WEB" ] && [[ $($NCMD /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *${NM_AUTHELIA_IP}* ]] && NOGOCHK=false || NOGOCHK=true - [ "${srvc}" == "headscale" ] && [ "${NTYPE}" == "HS" ] && [[ $($NCMD /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *${NM_SINGLESRVR_IP['HS']}* ]] && NOGOCHK=false + [ "${srvc}" == "gitea" ] && [ "${NTYPE}" == "WEB" ] && [[ $($NCMD /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1 | head -n1) != *${NM_AUTHELIA_IP}* ]] && NOGOCHK=false || NOGOCHK=true + [ "${srvc}" == "headscale" ] && [ "${NTYPE}" == "HS" ] && [[ $($NCMD /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1 | head -n1) != *${NM_SINGLESRVR_IP['HS']}* ]] && NOGOCHK=false [ "${srvc}" == "keepalived" ] && ([ "${nip}" == "10.2.1.2" ] || [ "${nip}" == "10.2.1.51" ]) && NOGOCHK=false if [ ${NOGOCHK} == true ]; then if [ "${ST_ACTION}" != "check" ]; then @@ -265,7 +265,7 @@ STATUS(){ # for srvc in "${!var2}"; do # NOGOCHK=true; - # [ "${srvc}" == "gitea" ] && [ "${NTYPE}" == "WEB" ] && [[ $($NCMD /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *${WEB_HOSTS[0]}* ]] && NOGOCHK=false; + # [ "${srvc}" == "gitea" ] && [ "${NTYPE}" == "WEB" ] && [[ $($NCMD /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1 | head -n1) != *${WEB_HOSTS[0]}* ]] && NOGOCHK=false; # if [ ${NOGOCHK} = true ]; then # if [ "${ST_ACTION}" != "check" ]; then # if [ "${ST_ACTION}" != "report" ]; then @@ -352,7 +352,7 @@ STATUS(){ fi for docker in "${!dockers}"; do if [ "${NTYPE}" == "WEB" ]; then - ([ "${docker}" == "vaultwarden" ] || [ "${docker}" == "heimdall" ] || [ "${docker}" == "authelia" ]) && [[ $($NCMD /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *${NM_AUTHELIA_IP}* ]] && NOGOCHK=false || NOGOCHK=true + ([ "${docker}" == "vaultwarden" ] || [ "${docker}" == "heimdall" ] || [ "${docker}" == "authelia" ]) && [[ $($NCMD /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1 | head -n1) != *${NM_AUTHELIA_IP}* ]] && NOGOCHK=false || NOGOCHK=true else NOGOCHK=true fi @@ -477,7 +477,7 @@ STATUS(){ if [ ! -z ${!var+x} ]; then var=${NTYPE}_HOSTS[@] for nip in "${!var}"; do - if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]] && [ "${nip}" != "${!PH}" ]; then + if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1 | head -n1) != *"${nip}"* ]] && [ "${nip}" != "${!PH}" ]; then if [ ! -f ${NM_FOLDER}/${!PH}.down ] && [ ! -f ${NM_TMPFOLDER}/${nip}.down ]; then var2=${NTYPE}_REPL_CHECK[@] for rcheck in "${!var2}"; do @@ -497,7 +497,7 @@ STATUS(){ if [ ! -z ${!var+x} ]; then var=${NTYPE}_HOSTS[@] for nip in "${!var}"; do - if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]] && [ "${nip}" != "${!PH}" ]; then + if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1 | head -n1) != *"${nip}"* ]] && [ "${nip}" != "${!PH}" ]; then if [ "${ST_ACTION}" != "check" ]; then echo -e " ${idsCL[LightCyan]}${NM_HOSTNAMES[${!PH}]} (${!PH}) <--> ${idsST[Bold]}${NM_HOSTNAMES[${nip}]}[${nip}]${idsST[Reset]}${idsCL[Default]}" DIVIDER false green @@ -623,7 +623,7 @@ It was down for $(SHOW_TIME ${toterrtime})" nid=1 var=${NTYPE}_HOSTS[@] 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 [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1 | head -n1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost' else NCMD="ssh root@${nip}"; LH='' fi if [ "${ST_ACTION}" != "check" ]; then