feature(BACKUP): parameterize log colourization

Closes github #9
This commit is contained in:
Asif Bacchus 2021-03-07 23:54:32 -07:00
parent 16f4c11f91
commit de76918e81

View File

@ -164,6 +164,10 @@ scriptHelp() {
textblock "Path to write log file"
defaultsTextblock "(scriptPath/scriptName.log)"
newline
switchTextblock "[SWITCH] --nc | --no-color | --no-colour"
textblock "Do NOT use ANSI colourization in the log file (in case your preferred log viewer does not support it)."
defaultsTextblock "(use ANSI colourization to make log file look good)"
newline
switchTextblock "--compression"
textblock "Compression algorithm(s) that borg should use. Please run 'borg help compression' for details."
defaultsTextblock "(not specified, use borg default of lz4)"
@ -252,6 +256,7 @@ trapExit() {
scriptPath="$( CDPATH='' cd -- "$( dirname -- "$0" )" && pwd -P )"
scriptName="$( basename "$0" )"
logFile="$scriptPath/${scriptName%.*}.log"
colourizeLogFile=1
warnCount=0
configDetails="$scriptPath/${scriptName%.*}.details"
err503Copied=0
@ -291,6 +296,10 @@ while [ $# -gt 0 ]; do
badParam empty "$@"
fi
;;
--nc|--no-color|--no-colour)
# do NOT colourize log file
colourizeLogFile=0
;;
-c|--config|--details)
# location of config details file
if [ -n "$2" ]; then
@ -436,6 +445,17 @@ fi
if [ -n "$borgCompression" ]; then
borgCreateParams="${borgCreateParams} --compression ${borgCompression}"
fi
# remove colourization if parameter specified
if [ "$colourizeLogFile" -eq 0 ]; then
bold=""
cyan=""
err=""
magenta=""
norm=""
ok=""
warn=""
yellow=""
fi
### read mailcow.conf and set vars as needed
# shellcheck source=./mailcow.conf.shellcheck