From aff13a0daff6b4e93c032ccf5afc04c997d825e2 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 12 Nov 2023 14:04:15 -0600 Subject: [PATCH] update --- inc/certs.inc | 2 +- inc/sites.inc | 168 +++++++++++++++++++++++++------------------------- 2 files changed, 85 insertions(+), 85 deletions(-) diff --git a/inc/certs.inc b/inc/certs.inc index 8cc9a1a0..0d6aaf1f 100755 --- a/inc/certs.inc +++ b/inc/certs.inc @@ -7,7 +7,7 @@ NEWCERT(){ else while [ $# -gt 0 ]; do case "${1}" in - -test) CERTTEST=1;; + -test|-t) CERTTEST=1;; *) NEW_CERT=${1};; esac shift diff --git a/inc/sites.inc b/inc/sites.inc index bce14e48..7245b9ed 100755 --- a/inc/sites.inc +++ b/inc/sites.inc @@ -165,7 +165,7 @@ NEWSITE(){ echo while [ $# -gt 0 ]; do case "$1" in - -test) CERTTEST=1;; + -test|-t) CERTTEST=1;; -site) NEW_SITE=${2};; -type) SITE_TYPE=${2};; -ssl) CREATE_SSL=${2};; @@ -616,6 +616,14 @@ NEWPROXYSITE_CREATE(){ SITEINFO(){ # start=`date +%s` dl=105 + EDIT=0; SEARCH=0 + while [ $# -gt 0 ]; do + case "${1}" in + -edit|-e) EDIT=1;; + -search|-s) SEARCH=${2};; + esac + shift + 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="" @@ -626,7 +634,7 @@ SITEINFO(){ twofacline=${twofacline%%:*} fi - if [ "${1}" == "edit" ]; then + if [ ${EDIT} -eq 1 ]; then [ "${2}" == "" ] && echo -e "${idsCL[LightGreen]}Choose a site from the list below to edit: ${idsCL[Default]}" else echo -e "${idsCL[LightGreen]}Local NGINX Sites ${idsCL[Default]}" @@ -634,92 +642,84 @@ SITEINFO(){ gosite=${NM_NGINXPATH[${RUN_NODE_TYPE}]}/sites-enabled declare -A SITELIST if [ "${gosite}" != "" ]; then - if [ "${1}" != "" ] && [ "${1}" != "edit" ]; then - sites=$(find ${gosite}/*${1,,}*.conf) + if [ ${SEARCH} -ne 0 ]; then + sites=$(find ${gosite}/*${SEARCH,,}*.conf) else sites=$(find ${gosite}/*.conf) fi - i=0 - # if [ "${1}" == "" ] || ([ "${1}" == "edit" ] && [ "${2}" == "" ]); then - for sitefile in ${sites[@]}; do - site=${sitefile##*/}; site=${site/.conf/} - if (( i % 12 == 0 )) || [ $i = 0 ]; then - DIVIDER false yellow ${dl} - [ "${1}" == "edit" ] && msg1='##) Site Address' || msg1='Site Address' - echo -en "${idsST[Bold]}${idsCL[LightCyan]}" - if [ "${1}" == "edit" ]; then - printf "%-32s %-8s %-6s %-6s %-6s %-6s %-6s %-8s\n" "${msg1}" "Type" "SSL" "HSTS" "WBSKT" "EXPLT" "LOCK" "Proxy Connection" - else - printf "%-28s %-8s %-6s %-6s %-6s %-6s %-6s %-8s\n" "${msg1}" "Type" "SSL" "HSTS" "WBSKT" "EXPLT" "LOCK" "Proxy Connection" - fi - echo -en "${idsST[Reset]}${idsCL[Default]}" - DIVIDER false yellow ${dl} - else - DIVIDER false darkGray ${dl} - fi - if [ "$(grep include/proxy.conf ${sitefile})" != "" ] || [ "$(grep proxy_pass ${sitefile})" != "" ]; then - type='Proxy' - if [ "$(grep include/proxy.conf ${sitefile})" != "" ]; then - server=$(grep 'set $server' ${sitefile}) - server=${server#*\"}; server=${server%\"*} - scheme=$(grep 'set $forward_scheme' ${sitefile}) - scheme=${scheme##* }; scheme=${scheme%;*} - port=$(grep 'set $port' ${sitefile}) - port=${port##* }; port=${port%;*} - proxyhost="${scheme}://${server}:${port}" - else - proxyhost="[ custom proxy_pass ]" - fi - else - type='HTTP' - proxyhost='' - fi - - [ "$(grep \#ssl_certificate ${sitefile})" != "" ] && ssl='' || ssl='Yes' - [ "$(grep '\#include conf.d/include/hsts-support.conf' ${sitefile})" != "" ] && hsts='' || hsts='Yes' - [ "$(grep '\#include conf.d/include/websocket-support.conf' ${sitefile})" != "" ] && wbskt='' || wbskt='Yes' - [ "$(grep '\#include conf.d/include/block-exploits.conf' ${sitefile})" != "" ] && explt='' || explt='Yes' - # [ "$(grep '\#include conf.d/include/secure-access.conf' ${sitefile})" != "" ] && lock='' || lock='Yes' - - if [ "$(grep '\#include conf.d/include/secure-access.conf' ${sitefile})" == "" ]; then - - sitefacline=$(echo "${autheliaconfig}" | grep -Fn ${site}) - sitefacline=${sitefacline%%:*} - if [ "${sitefacline}" == "" ]; then - lock='error' - # ssh root@${NM_AUTHELIA_IP} "sed -ie \"/domain: # Proxies only requiring username and password/a ~~~ - \\\"${site}\\\"\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml" - # ssh root@${NM_AUTHELIA_IP} "sed -i \"s/~~~/ /g\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml" - elif [ ${sitefacline} -lt ${onefacline} ]; then - lock='1FA' - elif [ ${sitefacline} -lt ${twofacline} ]; then - lock='2FA' - fi - else - lock='-' - fi - - - [ ${i} -lt 10 ] && ii=" ${i}" || ii=${i} - [ "${1}" == "edit" ] && msg1="${ii}) ${site}" || msg1="${site}" - if [ "${1}" == "edit" ]; then - printf "%-32s %-8s %-6s %-6s %-6s %-6s %-6s %-14s\n" "${msg1}" "${type}" "${ssl}" "${hsts}" "${wbskt}" "${explt}" "${lock}" "${proxyhost}" - else - printf "%-28s %-8s %-6s %-6s %-6s %-6s %-6s %-14s\n" "${msg1}" "${type}" "${ssl}" "${hsts}" "${wbskt}" "${explt}" "${lock}" "${proxyhost}" - fi - - SITELIST[${i}]=${site} - i=`expr $i + 1` - done - # else - # i=0 - # for sitefile in ${sites[@]}; do - # site=${sitefile##*/}; site=${site/.conf/} - # SITELIST[${i}]=${site} - # i=`expr $i + 1` - # done - # fi - if [ "${1}" == "edit" ]; then + i=0 + for sitefile in ${sites[@]}; do + site=${sitefile##*/}; site=${site/.conf/} + if (( i % 12 == 0 )) || [ $i = 0 ]; then + DIVIDER false yellow ${dl} + [ ${EDIT} -eq 1 ] && msg1='##) Site Address' || msg1='Site Address' + echo -en "${idsST[Bold]}${idsCL[LightCyan]}" + if [ ${EDIT} -eq 1 ]; then + printf "%-32s %-8s %-6s %-6s %-6s %-6s %-6s %-8s\n" "${msg1}" "Type" "SSL" "HSTS" "WBSKT" "EXPLT" "LOCK" "Proxy Connection" + else + printf "%-28s %-8s %-6s %-6s %-6s %-6s %-6s %-8s\n" "${msg1}" "Type" "SSL" "HSTS" "WBSKT" "EXPLT" "LOCK" "Proxy Connection" + fi + echo -en "${idsST[Reset]}${idsCL[Default]}" + DIVIDER false yellow ${dl} + else + DIVIDER false darkGray ${dl} + fi + if [ "$(grep include/proxy.conf ${sitefile})" != "" ] || [ "$(grep proxy_pass ${sitefile})" != "" ]; then + type='Proxy' + if [ "$(grep include/proxy.conf ${sitefile})" != "" ]; then + server=$(grep 'set $server' ${sitefile}) + server=${server#*\"}; server=${server%\"*} + scheme=$(grep 'set $forward_scheme' ${sitefile}) + scheme=${scheme##* }; scheme=${scheme%;*} + port=$(grep 'set $port' ${sitefile}) + port=${port##* }; port=${port%;*} + proxyhost="${scheme}://${server}:${port}" + else + proxyhost="[ custom proxy_pass ]" + fi + else + type='HTTP' + proxyhost='' + fi + + [ "$(grep \#ssl_certificate ${sitefile})" != "" ] && ssl='' || ssl='Yes' + [ "$(grep '\#include conf.d/include/hsts-support.conf' ${sitefile})" != "" ] && hsts='' || hsts='Yes' + [ "$(grep '\#include conf.d/include/websocket-support.conf' ${sitefile})" != "" ] && wbskt='' || wbskt='Yes' + [ "$(grep '\#include conf.d/include/block-exploits.conf' ${sitefile})" != "" ] && explt='' || explt='Yes' + # [ "$(grep '\#include conf.d/include/secure-access.conf' ${sitefile})" != "" ] && lock='' || lock='Yes' + + if [ "$(grep '\#include conf.d/include/secure-access.conf' ${sitefile})" == "" ]; then + + sitefacline=$(echo "${autheliaconfig}" | grep -Fn ${site}) + sitefacline=${sitefacline%%:*} + if [ "${sitefacline}" == "" ]; then + lock='error' + # ssh root@${NM_AUTHELIA_IP} "sed -ie \"/domain: # Proxies only requiring username and password/a ~~~ - \\\"${site}\\\"\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml" + # ssh root@${NM_AUTHELIA_IP} "sed -i \"s/~~~/ /g\" ${NM_DOCKER_COMPOSE_LOC['authelia']}/config/configuration.yml" + elif [ ${sitefacline} -lt ${onefacline} ]; then + lock='1FA' + elif [ ${sitefacline} -lt ${twofacline} ]; then + lock='2FA' + fi + else + lock='-' + fi + + + [ ${i} -lt 10 ] && ii=" ${i}" || ii=${i} + [ ${EDIT} -eq 1 ] && msg1="${ii}) ${site}" || msg1="${site}" + if [ ${EDIT} -eq 1 ]; then + printf "%-32s %-8s %-6s %-6s %-6s %-6s %-6s %-14s\n" "${msg1}" "${type}" "${ssl}" "${hsts}" "${wbskt}" "${explt}" "${lock}" "${proxyhost}" + else + printf "%-28s %-8s %-6s %-6s %-6s %-6s %-6s %-14s\n" "${msg1}" "${type}" "${ssl}" "${hsts}" "${wbskt}" "${explt}" "${lock}" "${proxyhost}" + fi + + SITELIST[${i}]=${site} + i=`expr $i + 1` + done + + if [ ${EDIT} -eq 1 ]; then function exitspacing { echo -e "\n\033[K\n\033[K"