Skip to content

Commit

Permalink
v 0.102.0
Browse files Browse the repository at this point in the history
- diagnostic : fix URL display.
- archivelogs : new argument « all » to archive even the current file.
  • Loading branch information
Darklg committed Oct 10, 2024
1 parent 49f8682 commit e521980
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
26 changes: 22 additions & 4 deletions bin/archivelogs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}");
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -98,4 +116,4 @@ function wputools_archive_logs(){

}

wputools_archive_logs;
wputools_archive_logs "$@";
2 changes: 1 addition & 1 deletion bin/diagnostic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions inc/autocomplete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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) )
;;
Expand Down
2 changes: 1 addition & 1 deletion wputools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e521980

Please sign in to comment.