From e521980b56ad1321cd8949795506042caab9c92a Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 10 Oct 2024 20:09:56 +0200 Subject: [PATCH] v 0.102.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - diagnostic : fix URL display. - archivelogs : new argument « all » to archive even the current file. --- bin/archivelogs.sh | 26 ++++++++++++++++++++++---- bin/diagnostic.sh | 2 +- inc/autocomplete.sh | 3 +++ wputools.sh | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/bin/archivelogs.sh b/bin/archivelogs.sh index 39b833a..ec87200 100644 --- a/bin/archivelogs.sh +++ b/bin/archivelogs.sh @@ -12,6 +12,8 @@ function wputools_archive_logs(){ local _log_file; local _log_file_ym; local _log_file_archive; + local _log_file_suffix; + local _log_file_suffix_content; local _nb_log_files_archived=0; local _EXCLUDED_YEARMONTHS; local _PREVIOUS_MONTH; @@ -23,6 +25,10 @@ function wputools_archive_logs(){ return; fi _logs_archive="${_logs_folder}archive/"; + if [ ! -d "${_logs_archive}" ]; then + mkdir "${_logs_archive}"; + fi + _log_file_suffix_content="--forced-"$(date +%Y%m%d%H%M%S); # Find if there are logs _logs_files=$(ls -1 "${_logs_folder}"); @@ -42,9 +48,16 @@ function wputools_archive_logs(){ # Loop through log files and archive them by year and month contained in the log file name for _log_file in ${_logs_files}; do + _log_file_suffix=''; + # Stop if the year and month are in the excluded list if [[ "${_EXCLUDED_YEARMONTHS}" == *"${_log_file}"* ]]; then - continue; + if [[ "${1}" == 'all' ]]; + then + _log_file_suffix="${_log_file_suffix_content}"; + else + continue; + fi fi # Stop if the file is not a log file @@ -65,7 +78,12 @@ function wputools_archive_logs(){ # Check if the first chars are in the excluded list if [[ "${_EXCLUDED_YEARMONTHS}" == *"${_log_file_ym}"* ]]; then - continue; + if [[ "${1}" == 'all' ]]; + then + _log_file_suffix="${_log_file_suffix_content}"; + else + continue; + fi fi # Create the folder if it does not exist @@ -83,7 +101,7 @@ function wputools_archive_logs(){ cd "${_logs_archive}"; for _log_file_ym in *; do if [ -d "${_log_file_ym}" ]; then - _log_file_archive="${_log_file_ym##*/}.tar.gz"; + _log_file_archive="${_log_file_ym##*/}${_log_file_suffix}.tar.gz"; tar -czf "${_logs_archive}${_log_file_archive}" "${_log_file_ym}"; rm -rf "${_log_file_ym}"; fi @@ -98,4 +116,4 @@ function wputools_archive_logs(){ } -wputools_archive_logs; +wputools_archive_logs "$@"; diff --git a/bin/diagnostic.sh b/bin/diagnostic.sh index f893b43..5cb7ade 100644 --- a/bin/diagnostic.sh +++ b/bin/diagnostic.sh @@ -11,7 +11,7 @@ if [[ "${1}" == 'code-profiler' ]];then wputools_add_files_to_excludes "wp-content/plugins/code-profiler-pro" wputools_add_files_to_excludes "wp-content/mu-plugins/0----code-profiler-pro.php" echo "Success! please go to :"; - _WPCLICOMMAND eval 'echo admin_url("admin.php?page=code-profiler-pro")."\n";'; + $_PHP_COMMAND "$_WPCLISRC" eval 'echo admin_url("admin.php?page=code-profiler-pro")."\n";'; return 0; fi; diff --git a/inc/autocomplete.sh b/inc/autocomplete.sh index be304c3..7b17a08 100644 --- a/inc/autocomplete.sh +++ b/inc/autocomplete.sh @@ -23,6 +23,9 @@ _wputools_complete() { COMPREPLY=( $(compgen -W "adminer anonymizedb archivelogs backup bduser cache cachewarm clean cleanhack codechecker dbexport dbimport debugfile detecthack diagnostic duplicatemenu generatemenus go importsite login muplugin nginx-convert plugin sample sandbox settings self-update src update wp wpconfig wpuwoo" -- $cur) ) elif [ $COMP_CWORD -eq 2 ]; then case "$prev" in + "archivelogs") + COMPREPLY=( $(compgen -W "all" -- $cur) ) + ;; "cache") COMPREPLY=( $(compgen -W "all opcache wprocket w3tc transient fvm object url purge-cli" -- $cur) ) ;; diff --git a/wputools.sh b/wputools.sh index f88e08b..2d72d24 100644 --- a/wputools.sh +++ b/wputools.sh @@ -2,7 +2,7 @@ WPUTools(){ -local _WPUTOOLS_VERSION='0.101.2'; +local _WPUTOOLS_VERSION='0.102.0'; local _PHP_VERSIONS=(7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 8.5 9.0) local _PHP_VERSIONS_OBSOLETES=(7.0 7.1 7.2 7.3 7.4 8.0) local _PHP_VERSIONS_ADVANCED=(8.2 8.3 8.4 8.5 9.0)