mirror of
https://github.com/CISOfy/lynis.git
synced 2025-07-27 15:54:09 +02:00
Remove colors properly with one function (contribution: Mike Slifcak at Pindrop
This commit is contained in:
parent
d5890b8a75
commit
7f25a1f00e
@ -67,6 +67,7 @@
|
|||||||
# PortIsListening Check if machine is listening on specified protocol and port
|
# PortIsListening Check if machine is listening on specified protocol and port
|
||||||
# Progress Show progress on screen
|
# Progress Show progress on screen
|
||||||
# RandomString Show a random string
|
# RandomString Show a random string
|
||||||
|
# RemoveColors Reset all colors
|
||||||
# RemovePIDFile Remove PID file
|
# RemovePIDFile Remove PID file
|
||||||
# RemoveTempFiles Remove temporary files
|
# RemoveTempFiles Remove temporary files
|
||||||
# Report Add string of data to report file
|
# Report Add string of data to report file
|
||||||
@ -444,8 +445,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Name : Display()
|
# Name : Display()
|
||||||
# Description : Show text on screen, with markup
|
# Description : Show text on screen, with markup
|
||||||
@ -1849,6 +1848,38 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Name : RemoveColors()
|
||||||
|
# RemoveColors Clear color settings for --no-colors (see include/consts)
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
RemoveColors() {
|
||||||
|
COLORS=0 # disable most color selections
|
||||||
|
NORMAL=""
|
||||||
|
WARNING=""
|
||||||
|
SECTION=""
|
||||||
|
NOTICE=""
|
||||||
|
OK=""
|
||||||
|
BAD=
|
||||||
|
|
||||||
|
# Normal color names
|
||||||
|
CYAN=""
|
||||||
|
BLUE=""
|
||||||
|
BROWN=""
|
||||||
|
DARKGRAY=""
|
||||||
|
GRAY=""
|
||||||
|
GREEN=""
|
||||||
|
LIGHTBLUE=""
|
||||||
|
MAGENTA=""
|
||||||
|
PURPLE=""
|
||||||
|
RED=""
|
||||||
|
YELLOW=""
|
||||||
|
WHITE=""
|
||||||
|
|
||||||
|
# Colors with background
|
||||||
|
BG_BLUE=
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Name : RemovePIDFile()
|
# Name : RemovePIDFile()
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -200,7 +200,7 @@ if [ $# -gt 0 ]; then
|
|||||||
case $1 in
|
case $1 in
|
||||||
"--brief" | "--br") BRIEF_OUTPUT=1 ;;
|
"--brief" | "--br") BRIEF_OUTPUT=1 ;;
|
||||||
"--configured-only" | "--co") CONFIGURED_ONLY_OUTPUT=1 ;;
|
"--configured-only" | "--co") CONFIGURED_ONLY_OUTPUT=1 ;;
|
||||||
"--nocolors" | "--nc") COLORED_OUTPUT=0 ;;
|
"--nocolors" | "--no-colors" | "--nc") COLORED_OUTPUT=0; COLORS=0 ;;
|
||||||
*)
|
*)
|
||||||
${ECHOCMD} "${RED}Error${NORMAL}: Invalid argument provided to 'lynis show settings'\n\n"
|
${ECHOCMD} "${RED}Error${NORMAL}: Invalid argument provided to 'lynis show settings'\n\n"
|
||||||
${ECHOCMD} "Suggestions:"
|
${ECHOCMD} "Suggestions:"
|
||||||
@ -209,7 +209,7 @@ if [ $# -gt 0 ]; then
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
if [ ${COLORED_OUTPUT} -eq 0 ]; then BLUE=""; CYAN=""; GRAY=""; WHITE=""; fi
|
if [ ${COLORED_OUTPUT} -eq 0 ]; then RemoveColors; fi
|
||||||
# Sort all settings and display them
|
# Sort all settings and display them
|
||||||
SETTINGS=$(sort ${SETTINGS_FILE} | sed 's/ /:space:/g')
|
SETTINGS=$(sort ${SETTINGS_FILE} | sed 's/ /:space:/g')
|
||||||
for LINE in ${SETTINGS}; do
|
for LINE in ${SETTINGS}; do
|
||||||
|
@ -162,8 +162,8 @@
|
|||||||
# Cronjob support
|
# Cronjob support
|
||||||
--cronjob | --cron)
|
--cronjob | --cron)
|
||||||
CRONJOB=1
|
CRONJOB=1
|
||||||
CHECK=1; QUICKMODE=1; NEVERBREAK=1 # Use some defaults (-c, -Q, no colors)
|
CHECK=1; QUICKMODE=1; COLORS=0; NEVERBREAK=1 # Use some defaults (-c, -Q, no colors)
|
||||||
NORMAL=""; WARNING=""; SECTION=""; NOTICE=""; OK=""; BAD=""; CYAN=""; MAGENTA=""; PURPLE=""; YELLOW=""; WHITE=""; GREEN=""; RED="" # Remove colors
|
RemoveColors
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Perform tests with additional debugging information on screen
|
# Perform tests with additional debugging information on screen
|
||||||
@ -225,7 +225,7 @@
|
|||||||
# Don't use colors
|
# Don't use colors
|
||||||
--no-colors | --nocolors)
|
--no-colors | --nocolors)
|
||||||
COLORS=0
|
COLORS=0
|
||||||
BG_BLUE=""; NORMAL=""; WARNING=""; SECTION=""; NOTICE=""; OK=""; BAD=""; BLUE=""; CYAN=""; LIGHTBLUE=""; MAGENTA=""; PURPLE=""; YELLOW=""; WHITE=""; GREEN=""; RED=""
|
RemoveColors
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Disable logging
|
# Disable logging
|
||||||
|
Loading…
x
Reference in New Issue
Block a user