From 71b1392dce2b46f17e8bc210c607c908149a157a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Tue, 7 Jan 2020 16:10:01 +0100 Subject: [PATCH] Add specific colors for debug messages --- xymon/tar.client.logfiles.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xymon/tar.client.logfiles.sh b/xymon/tar.client.logfiles.sh index 0413ab9..a0f30a7 100755 --- a/xymon/tar.client.logfiles.sh +++ b/xymon/tar.client.logfiles.sh @@ -11,6 +11,12 @@ ## Enable (0) or disable (1) debug debug=0 +## Colors {{{ +c_redb='\033[1;31m' +c_magentab='\033[1;35m' +c_reset='\033[0m' +## }}} + ## Manage files of year date_year="2019" @@ -31,14 +37,14 @@ tar_file_name="${date_year}.${current_dir}${xz_compression_lvl}.tar.xz" # }}} -[ "${debug}" -eq "0" ] && printf '%b\n' "Create an archive for ${current_dir} files between ${date_start} and ${date_end} using XZ's compression level : ${xz_compression_lvl}." +[ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "Create an archive for ${current_dir} files between ${date_start} and ${date_end} using XZ's compression level : ${xz_compression_lvl}." ## Get the list of files between the 2 dates and ignore tar files find . -type f -newermt "${date_start}" -not -newermt "${date_end}" -not -iname "*.tar*" -print0 | tar cJf "${tar_file_name}" --null -T - ## Check previous return code and if the archive exists with size > 0 if [ "${?}" -eq "0" ] && [ -s "${tar_file_name}" ]; then - [ "${debug}" -eq "0" ] && printf '%b\n' "${tar_file_name} successfully created, the files can be deleted." + [ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "${tar_file_name} successfully created, the files can be deleted." find . -type f -newermt "${date_start}" -not -newermt "${date_end}" -not -iname "*.tar*" -delete fi