From 588eb6850218d25738bc6f0002cc3753bf5ce486 Mon Sep 17 00:00:00 2001 From: Christoph Date: Fri, 4 Aug 2023 01:39:40 +0200 Subject: [PATCH] fix error determin configuration file. --- occ_file_scan_all_accounts.sh | 35 ++++++++++++++++++++++------------- occ_file_scan_app-data.sh | 33 ++++++++++++++++++++------------- occ_maintenance.sh | 4 +++- occ_manual_upgrade.sh | 33 ++++++++++++++++++++------------- occ_update_apps.sh | 35 ++++++++++++++++++++++------------- 5 files changed, 87 insertions(+), 53 deletions(-) diff --git a/occ_file_scan_all_accounts.sh b/occ_file_scan_all_accounts.sh index 7c63d30..e89bc39 100755 --- a/occ_file_scan_all_accounts.sh +++ b/occ_file_scan_all_accounts.sh @@ -133,13 +133,11 @@ error(){ } warn (){ - echo "" if $terminal ; then + echo "" echo -e " [ \033[33m\033[1mWarning\033[m ]: $*" - else - echo " [ Warning ]: $*" + echo "" fi - echo "" } info (){ @@ -174,6 +172,14 @@ blank_line() { } +# - Running in a terminal? +# - +if [[ -t 1 ]] ; then + terminal=true +else + terminal=false +fi + # ---------- # - Jobhandling @@ -214,6 +220,17 @@ if [[ -z "$WEBSITE" ]] ; then # source ${snippet_dir}/get-cloud-instance-to-update.sh +else + + while IFS='' read -r -d '' _conf_file ; do + if $(grep -E -q "WEBSITE=\"?${WEBSITE}\"?" ${_conf_file} 2> /dev/null) ; then + conf_file="${_conf_file}" + break + fi + done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0) + + # conf_file="${conf_dir}/${WEBSITE}.conf" + fi @@ -227,7 +244,7 @@ DEFAULT_HTTP_GROUP="www-data" DEFAULT_PHP_ENGINE='FPM' echo "" -echononl " Include Configuration file.." +echononl " Include Configuration file '$(basename "${conf_file}")'.." if [[ ! -f $conf_file ]]; then echo_failed fatal "Missing configuration file '$conf_file'." @@ -264,14 +281,6 @@ else SYSTEMD_EXISTS=true fi -# - Running in a terminal? -# - -if [[ -t 1 ]] ; then - terminal=true -else - terminal=false -fi - #clear if $terminal ; then diff --git a/occ_file_scan_app-data.sh b/occ_file_scan_app-data.sh index c8f7e43..10acd98 100755 --- a/occ_file_scan_app-data.sh +++ b/occ_file_scan_app-data.sh @@ -140,13 +140,11 @@ error(){ } warn (){ - echo "" if $terminal ; then + echo "" echo -e " [ \033[33m\033[1mWarning\033[m ]: $*" - else - echo " [ Warning ]: $*" + echo "" fi - echo "" } info (){ @@ -181,6 +179,14 @@ blank_line() { } +# - Running in a terminal? +# - +if [[ -t 1 ]] ; then + terminal=true +else + terminal=false +fi + # ---------- # - Jobhandling @@ -221,6 +227,15 @@ if [[ -z "$WEBSITE" ]] ; then # source ${snippet_dir}/get-cloud-instance-to-update.sh +else + while IFS='' read -r -d '' _conf_file ; do + if $(grep -E -q "WEBSITE=\"?${WEBSITE}\"?" ${_conf_file} 2> /dev/null) ; then + conf_file="${_conf_file}" + break + fi + done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0) + # conf_file="${conf_dir}/${WEBSITE}.conf" + fi @@ -234,7 +249,7 @@ DEFAULT_HTTP_GROUP="www-data" DEFAULT_PHP_ENGINE='FPM' echo "" -echononl " Include Configuration file.." +echononl " Include Configuration file '$(basename "${conf_file}")'.." if [[ ! -f $conf_file ]]; then echo_failed fatal "Missing configuration file '$conf_file'." @@ -271,14 +286,6 @@ else SYSTEMD_EXISTS=true fi -# - Running in a terminal? -# - -if [[ -t 1 ]] ; then - terminal=true -else - terminal=false -fi - #clear if $terminal ; then diff --git a/occ_maintenance.sh b/occ_maintenance.sh index 56514a8..2791d1e 100755 --- a/occ_maintenance.sh +++ b/occ_maintenance.sh @@ -226,15 +226,17 @@ if [[ -z "$WEBSITE" ]] ; then # source ${snippet_dir}/get-cloud-instance-to-update.sh - #fatal "No website ios given on commandline - Missing Parameter '-s '" else + while IFS='' read -r -d '' _conf_file ; do if $(grep -E -q "WEBSITE=\"?${WEBSITE}\"?" ${_conf_file} 2> /dev/null) ; then conf_file="${_conf_file}" break fi done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0) + # conf_file="${conf_dir}/${WEBSITE}.conf" + fi diff --git a/occ_manual_upgrade.sh b/occ_manual_upgrade.sh index 8447fb6..4c8358d 100755 --- a/occ_manual_upgrade.sh +++ b/occ_manual_upgrade.sh @@ -139,13 +139,11 @@ error(){ } warn (){ - echo "" if $terminal ; then + echo "" echo -e " [ \033[33m\033[1mWarning\033[m ]: $*" - else - echo " [ Warning ]: $*" + echo "" fi - echo "" } info (){ @@ -180,6 +178,14 @@ blank_line() { } +# - Running in a terminal? +# - +if [[ -t 1 ]] ; then + terminal=true +else + terminal=false +fi + # ---------- # - Jobhandling @@ -220,7 +226,16 @@ if [[ -z "$WEBSITE" ]] ; then # source ${snippet_dir}/get-cloud-instance-to-update.sh - #fatal "No website ios given on commandline - Missing Parameter '-s '" +else + while IFS='' read -r -d '' _conf_file ; do + if $(grep -E -q "WEBSITE=\"?${WEBSITE}\"?" ${_conf_file} 2> /dev/null) ; then + conf_file="${_conf_file}" + break + fi + done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0) + + # conf_file="${conf_dir}/${WEBSITE}.conf" + fi @@ -271,14 +286,6 @@ else SYSTEMD_EXISTS=true fi -# - Running in a terminal? -# - -if [[ -t 1 ]] ; then - terminal=true -else - terminal=false -fi - #clear if $terminal ; then diff --git a/occ_update_apps.sh b/occ_update_apps.sh index 5988b95..56b824e 100755 --- a/occ_update_apps.sh +++ b/occ_update_apps.sh @@ -139,13 +139,11 @@ error(){ } warn (){ - echo "" if $terminal ; then + echo "" echo -e " [ \033[33m\033[1mWarning\033[m ]: $*" - else - echo " [ Warning ]: $*" + echo "" fi - echo "" } info (){ @@ -180,6 +178,14 @@ blank_line() { } +# - Running in a terminal? +# - +if [[ -t 1 ]] ; then + terminal=true +else + terminal=false +fi + # ---------- # - Jobhandling @@ -221,6 +227,17 @@ if [[ -z "$WEBSITE" ]] ; then # source ${snippet_dir}/get-cloud-instance-to-update.sh +else + + while IFS='' read -r -d '' _conf_file ; do + if $(grep -E -q "WEBSITE=\"?${WEBSITE}\"?" ${_conf_file} 2> /dev/null) ; then + conf_file="${_conf_file}" + break + fi + done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0) + + # conf_file="${conf_dir}/${WEBSITE}.conf" + fi @@ -234,7 +251,7 @@ DEFAULT_HTTP_GROUP="www-data" DEFAULT_PHP_ENGINE='FPM' echo "" -echononl " Include Configuration file.." +echononl " Include Configuration file.. '$(basename "${conf_file}")'" if [[ ! -f $conf_file ]]; then echo_failed fatal "Missing configuration file '$conf_file'." @@ -271,14 +288,6 @@ else SYSTEMD_EXISTS=true fi -# - Running in a terminal? -# - -if [[ -t 1 ]] ; then - terminal=true -else - terminal=false -fi - #clear if $terminal ; then