Export status without colors
This commit is contained in:
parent
66bdae2365
commit
9c7731e5aa
|
@ -7,6 +7,8 @@ and this project **does not adhere to [Semantic Versioning](http://semver.org/sp
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
* Export status without colors
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
14
minifirewall
14
minifirewall
|
@ -147,6 +147,9 @@ fi
|
||||||
# }
|
# }
|
||||||
## Beware that commands executed from included files are not modified by this trick.
|
## Beware that commands executed from included files are not modified by this trick.
|
||||||
|
|
||||||
|
remove_colors() {
|
||||||
|
sed -r 's/\x1B\[(;?[0-9]{1,3})+[mGK]//g'
|
||||||
|
}
|
||||||
syslog_info() {
|
syslog_info() {
|
||||||
if [ -x "${LOGGER_BIN}" ]; then
|
if [ -x "${LOGGER_BIN}" ]; then
|
||||||
${LOGGER_BIN} -t "${NAME}" -p daemon.info "$1"
|
${LOGGER_BIN} -t "${NAME}" -p daemon.info "$1"
|
||||||
|
@ -268,9 +271,9 @@ check_unpersisted_state() {
|
||||||
elif [ -z "${diff_bin}" ]; then
|
elif [ -z "${diff_bin}" ]; then
|
||||||
printf "${YELLOW}skip state comparison (Can't find diff command)${RESET}\n" >&2
|
printf "${YELLOW}skip state comparison (Can't find diff command)${RESET}\n" >&2
|
||||||
else
|
else
|
||||||
# store current state
|
# store current state (without colors)
|
||||||
mkdir -p "$(dirname "${STATE_FILE_CURRENT}")"
|
mkdir -p "$(dirname "${STATE_FILE_CURRENT}")"
|
||||||
status_without_numbers > "${STATE_FILE_CURRENT}"
|
status_without_numbers | remove_colors > "${STATE_FILE_CURRENT}"
|
||||||
|
|
||||||
# clean previous diff file
|
# clean previous diff file
|
||||||
rm -f "${STATE_FILE_DIFF}"
|
rm -f "${STATE_FILE_DIFF}"
|
||||||
|
@ -310,9 +313,9 @@ report_state_changes() {
|
||||||
check_unpersisted_state
|
check_unpersisted_state
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Then reset the known state
|
# Then reset the known state (without colors)
|
||||||
mkdir -p "$(dirname "${STATE_FILE_LATEST}")"
|
mkdir -p "$(dirname "${STATE_FILE_LATEST}")"
|
||||||
status_without_numbers > "${STATE_FILE_LATEST}"
|
status_without_numbers | remove_colors > "${STATE_FILE_LATEST}"
|
||||||
|
|
||||||
# But if there is a previous known state
|
# But if there is a previous known state
|
||||||
# let's compare with the new known state
|
# let's compare with the new known state
|
||||||
|
@ -920,8 +923,9 @@ stop() {
|
||||||
|
|
||||||
printf "${BLUE}flushing all rules and accepting everything${RESET}\n"
|
printf "${BLUE}flushing all rules and accepting everything${RESET}\n"
|
||||||
|
|
||||||
|
# Save previous state (without colors)
|
||||||
mkdir -p "$(dirname "${STATE_FILE_PREVIOUS}")"
|
mkdir -p "$(dirname "${STATE_FILE_PREVIOUS}")"
|
||||||
status_without_numbers > "${STATE_FILE_PREVIOUS}"
|
status_without_numbers | remove_colors > "${STATE_FILE_PREVIOUS}"
|
||||||
|
|
||||||
# Delete all rules
|
# Delete all rules
|
||||||
${IPT} -F INPUT
|
${IPT} -F INPUT
|
||||||
|
|
Loading…
Reference in a new issue