monitor: suppress more errors

This commit is contained in:
tschettervictor
2025-07-22 17:18:25 -06:00
committed by GitHub
parent 21f8712643
commit a3f450c3e3

View File

@@ -144,7 +144,7 @@ for _jail in ${JAILS}; do
add)
[ -z "${SERVICE}" ] && usage
for _service in $(echo "${SERVICE}" | tr , ' '); do
if ! grep -qE "^${_service}\$" "${bastille_jail_monitor}" 2>/dev/null 2>&1; then
if ! grep -qEs "^${_service}\$" "${bastille_jail_monitor}" 2>/dev/null 2>&1; then
echo "${_service}" >> "${bastille_jail_monitor}"
echo "$(date '+%Y-%m-%d %H:%M:%S'): Added monitor for ${_service} on ${_jail}" >> "${bastille_monitor_logfile}"
fi
@@ -154,7 +154,7 @@ for _jail in ${JAILS}; do
[ -z "${SERVICE}" ] && usage
for _service in $(echo "${SERVICE}" | tr , ' '); do
[ ! -f "${bastille_jail_monitor}" ] && break # skip if no monitor file
if grep -qE "^${_service}\$" "${bastille_jail_monitor}" 2>/dev/null 2>&1; then
if grep -qEs "^${_service}\$" "${bastille_jail_monitor}" 2>/dev/null 2>&1; then
sed -i '' "/^${_service}\$/d" "${bastille_jail_monitor}"
echo "$(date '+%Y-%m-%d %H:%M:%S'): Removed monitor for ${_service} on ${_jail}" >> "${bastille_monitor_logfile}"
fi
@@ -168,7 +168,7 @@ for _jail in ${JAILS}; do
usage # Only one service per query
fi
[ ! -f "${bastille_jail_monitor}" ] && continue # skip if there is no monitor file
if grep -qE "^${SERVICE}\$" "${bastille_jail_monitor}" 2>/dev/null 2>&1; then
if grep -qEs "^${SERVICE}\$" "${bastille_jail_monitor}" 2>/dev/null 2>&1; then
echo "${_jail}"
continue
fi