From 0c78ebae8865778e2bf802d23e063865c9c6bb21 Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 27 Dec 2019 13:15:58 -0400 Subject: [PATCH] Fix to match exact container name, add missing quotes --- usr/local/share/bastille/start.sh | 6 +++--- usr/local/share/bastille/stop.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/usr/local/share/bastille/start.sh b/usr/local/share/bastille/start.sh index c018a04c..ac0134a4 100644 --- a/usr/local/share/bastille/start.sh +++ b/usr/local/share/bastille/start.sh @@ -54,16 +54,16 @@ if [ "${TARGET}" = 'ALL' ]; then JAILS=$(bastille list jails) fi if [ "${TARGET}" != 'ALL' ]; then - JAILS=$(bastille list jails | grep -w "${TARGET}") + JAILS=$(bastille list jails | awk "/^${TARGET}$/") fi for _jail in ${JAILS}; do ## test if running - if [ $(jls name | grep -w ${_jail}) ]; then + if [ "$(jls name | awk "/^${_jail}$/")" ]; then echo -e "${COLOR_RED}[${_jail}]: Already started.${COLOR_RESET}" ## test if not running - elif [ ! $(jls name | grep -w ${_jail}) ]; then + elif [ ! "$(jls name | awk "/^${_jail}$/")" ]; then echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}" jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -c ${_jail} diff --git a/usr/local/share/bastille/stop.sh b/usr/local/share/bastille/stop.sh index 593d1553..0d63907a 100644 --- a/usr/local/share/bastille/stop.sh +++ b/usr/local/share/bastille/stop.sh @@ -54,16 +54,16 @@ if [ "${TARGET}" = 'ALL' ]; then JAILS=$(jls name) fi if [ "${TARGET}" != 'ALL' ]; then - JAILS=$(jls name | grep -w "${TARGET}") + JAILS=$(jls name | awk "/^${TARGET}$/") fi for _jail in ${JAILS}; do ## test if not running - if [ ! $(jls name | grep -w "${_jail}") ]; then + if [ ! "$(jls name | awk "/^${_jail}$/")" ]; then echo -e "${COLOR_RED}[${_jail}]: Not started.${COLOR_RESET}" ## test if running - elif [ $(jls name | grep -w "${_jail}") ]; then + elif [ "$(jls name | awk "/^${_jail}$/")" ]; then ## remove ip4.addr from firewall table:jails if [ ! -z "${bastille_jail_loopback}" ]; then pfctl -q -t jails -T delete $(jls -j ${_jail} ip4.addr)