From 47a3003f41db70bf24632db35df5be6e33ea20b1 Mon Sep 17 00:00:00 2001 From: Christer Edwards Date: Thu, 21 Nov 2019 16:49:00 -0700 Subject: [PATCH] update for 0.5.20191125 --- AUTHORS.md | 30 +++++++++++++ usr/local/share/bastille/bootstrap.sh | 23 ++++++++-- usr/local/share/bastille/cmd.sh | 13 +++--- usr/local/share/bastille/console.sh | 17 +++++--- usr/local/share/bastille/cp.sh | 14 +++--- usr/local/share/bastille/create.sh | 2 +- usr/local/share/bastille/htop.sh | 8 ++-- usr/local/share/bastille/pkg.sh | 13 +++--- usr/local/share/bastille/service.sh | 13 +++--- usr/local/share/bastille/start.sh | 19 ++++++--- usr/local/share/bastille/stop.sh | 25 ++++++++--- usr/local/share/bastille/sysrc.sh | 13 +++--- usr/local/share/bastille/template.sh | 61 ++++++++++++++++++--------- usr/local/share/bastille/top.sh | 8 ++-- usr/local/share/bastille/zfs.sh | 10 +++-- 15 files changed, 192 insertions(+), 77 deletions(-) create mode 100644 AUTHORS.md diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 00000000..e6135fc4 --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1,30 @@ +# AUTHORS + +## Lead + +Christer Edwards [christer.edwards@gmail.com] + +## Contributors + +Barry McCormick +Jose Rivera +Giacomo Olgeni +Jan-Piet Mens + +### Special thanks +Software doesn't happen in a vacuum. Thank you to the following people who may +not be found in the commit history. + +Barry McCormick +Carlos Meza +Casandra Woodcox +Clint Savage +G. Clifford Williams +Jack Thomasson +Jun C Park +Justin Desilets +Larry Raab +Nate Taylor +Ryan Simpkins +Tim Gelter +Trevor Sharpe diff --git a/usr/local/share/bastille/bootstrap.sh b/usr/local/share/bastille/bootstrap.sh index 6d9bdda6..08f34405 100644 --- a/usr/local/share/bastille/bootstrap.sh +++ b/usr/local/share/bastille/bootstrap.sh @@ -32,7 +32,7 @@ . /usr/local/etc/bastille/bastille.conf usage() { - echo -e "${COLOR_RED}Usage: bastille bootstrap [release|template].${COLOR_RESET}" + echo -e "${COLOR_RED}Usage: bastille bootstrap [release|template] [update].${COLOR_RESET}" exit 1 } @@ -337,6 +337,18 @@ bootstrap_release() { } bootstrap_template() { + + ## ${bastille_templatesdir} + if [ ! -d "${bastille_templatesdir}" ]; then + if [ "${bastille_zfs_enable}" = "YES" ]; then + if [ ! -z "${bastille_zfs_zpool}" ]; then + zfs create ${bastille_zfs_options} -o mountpoint=${bastille_templatesdir} ${bastille_zfs_zpool}/${bastille_zfs_prefix}/templates + fi + else + mkdir -p "${bastille_templatesdir}" + fi + fi + ## define basic variables _url=${BASTILLE_TEMPLATE_URL} _user=${BASTILLE_TEMPLATE_USER} @@ -382,7 +394,9 @@ bootstrap_template() { echo -e "${COLOR_GREEN}Detected OVERLAY hook.${COLOR_RESET}" while read _dir; do echo -e "${COLOR_GREEN}[${_dir}]:${COLOR_RESET}" - tree -a ${_template}/${_dir} + if [ -x $(which tree) ]; then + tree -a ${_template}/${_dir} + fi done < ${_template}/OVERLAY echo fi @@ -391,7 +405,9 @@ bootstrap_template() { echo -e "${COLOR_YELLOW}CONFIG deprecated; rename to OVERLAY.${COLOR_RESET}" while read _dir; do echo -e "${COLOR_GREEN}[${_dir}]:${COLOR_RESET}" - tree -a ${_template}/${_dir} + if [ -x $(which tree) ]; then + tree -a ${_template}/${_dir} + fi done < ${_template}/CONFIG fi @@ -446,7 +462,6 @@ http?://github.com/*/*|http?://gitlab.com/*/*) BASTILLE_TEMPLATE_REPO=$(echo "${1}" | awk -F / '{ print $5 }') echo -e "${COLOR_GREEN}Template: ${1}${COLOR_RESET}" echo - bootstrap_directories bootstrap_template ;; network) diff --git a/usr/local/share/bastille/cmd.sh b/usr/local/share/bastille/cmd.sh index 795a88cc..3bcff46d 100644 --- a/usr/local/share/bastille/cmd.sh +++ b/usr/local/share/bastille/cmd.sh @@ -42,19 +42,22 @@ help|-h|--help) ;; esac -if [ $# -gt 2 ] || [ $# -lt 2 ]; then +if [ $# -lt 2 ]; then usage fi -if [ "$1" = 'ALL' ]; then +TARGET="${1}" +shift + +if [ "$TARGET" = 'ALL' ]; then JAILS=$(jls name) fi -if [ "$1" != 'ALL' ]; then - JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)") +if [ "$TARGET" != 'ALL' ]; then + JAILS=$(jls name | grep -w "${1}") fi for _jail in ${JAILS}; do echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}" - jexec -l ${_jail} $2 + jexec -l ${_jail} $@ echo done diff --git a/usr/local/share/bastille/console.sh b/usr/local/share/bastille/console.sh index 0e9ba154..1b9e1419 100644 --- a/usr/local/share/bastille/console.sh +++ b/usr/local/share/bastille/console.sh @@ -42,18 +42,25 @@ help|-h|--help) ;; esac -if [ $# -gt 1 ] || [ $# -lt 1 ]; then +if [ $# -gt 2 ] || [ $# -lt 1 ]; then usage fi -if [ "$1" = 'ALL' ]; then + +TARGET="${1}" + +if [ "$TARGET" = 'ALL' ]; then JAILS=$(jls name) fi -if [ "$1" != 'ALL' ]; then - JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)") +if [ "$TARGET" != 'ALL' ]; then + JAILS=$(jls name | grep -w "${1}") fi for _jail in ${JAILS}; do echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}" - jexec -l ${_jail} /usr/bin/login -f root + if [ ! -z "${2}" ]; then + jexec -l ${_jail} /usr/bin/login -f "${2}" + else + jexec -l ${_jail} /usr/bin/login -f root + fi echo done diff --git a/usr/local/share/bastille/cp.sh b/usr/local/share/bastille/cp.sh index 73dc195b..4a23a004 100644 --- a/usr/local/share/bastille/cp.sh +++ b/usr/local/share/bastille/cp.sh @@ -32,7 +32,7 @@ . /usr/local/etc/bastille/bastille.conf usage() { - echo -e "${COLOR_RED}Usage: bastille cp [ALL|glob] '/path/to/source' 'path/to/dest'.${COLOR_RESET}" + echo -e "${COLOR_RED}Usage: bastille cp [ALL|glob] /path/to/source path/to/dest.${COLOR_RESET}" exit 1 } @@ -47,16 +47,20 @@ if [ $# -gt 3 ] || [ $# -lt 3 ]; then usage fi -if [ "$1" = 'ALL' ]; then +TARGET="${1}" +CPSOURCE="${2}" +CPDEST="${3}" + +if [ "$TARGET" = 'ALL' ]; then JAILS=$(jls name) fi -if [ "$1" != 'ALL' ]; then - JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)") +if [ "$TARGET" != 'ALL' ]; then + JAILS=$(jls name | grep -w "${1}") fi for _jail in ${JAILS}; do bastille_jail_path="$(jls -j "${_jail}" path)" echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}" - cp -av "$2" "${bastille_jail_path}/$3" + cp -av "${CPSOURCE}" "${bastille_jail_path}/${CPDEST}" echo done diff --git a/usr/local/share/bastille/create.sh b/usr/local/share/bastille/create.sh index 92be0976..7f11825a 100644 --- a/usr/local/share/bastille/create.sh +++ b/usr/local/share/bastille/create.sh @@ -37,7 +37,7 @@ usage() { } running_jail() { - jls name | grep -E "(^|\b)${NAME}($|\b)" + jls name | grep -w "${NAME}" } validate_ip() { diff --git a/usr/local/share/bastille/htop.sh b/usr/local/share/bastille/htop.sh index b69ef548..81261d05 100644 --- a/usr/local/share/bastille/htop.sh +++ b/usr/local/share/bastille/htop.sh @@ -47,11 +47,13 @@ if [ $# -gt 1 ] || [ $# -lt 1 ]; then usage fi -if [ "$1" = 'ALL' ]; then +TARGET="${1}" + +if [ "$TARGET" = 'ALL' ]; then JAILS=$(jls name) fi -if [ "$1" != 'ALL' ]; then - JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)") +if [ "$TARGET" != 'ALL' ]; then + JAILS=$(jls name | grep -w "${1}") fi for _jail in ${JAILS}; do diff --git a/usr/local/share/bastille/pkg.sh b/usr/local/share/bastille/pkg.sh index 0c4ef7c9..85bbefa6 100644 --- a/usr/local/share/bastille/pkg.sh +++ b/usr/local/share/bastille/pkg.sh @@ -42,19 +42,22 @@ help|-h|--help) ;; esac -if [ $# -gt 2 ] || [ $# -lt 2 ]; then +if [ $# -lt 2 ]; then usage fi -if [ "$1" = 'ALL' ]; then +TARGET="${1}" +shift + +if [ "${TARGET}" = 'ALL' ]; then JAILS=$(jls name) fi -if [ "$1" != 'ALL' ]; then - JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)") +if [ "${TARGET}" != 'ALL' ]; then + JAILS=$(jls name | grep -w "${TARGET}") fi for _jail in ${JAILS}; do echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}" - jexec -l ${_jail} /usr/sbin/pkg $2 + jexec -l ${_jail} /usr/sbin/pkg $@ echo done diff --git a/usr/local/share/bastille/service.sh b/usr/local/share/bastille/service.sh index a943c4a4..b983e59b 100644 --- a/usr/local/share/bastille/service.sh +++ b/usr/local/share/bastille/service.sh @@ -42,20 +42,23 @@ help|-h|--help) ;; esac -if [ $# -gt 2 ] || [ $# -lt 2 ]; then +if [ $# -lt 2 ]; then usage fi -if [ "$1" = 'ALL' ]; then +TARGET=$1 +shift + +if [ "$TARGET" = 'ALL' ]; then JAILS=$(jls name) fi -if [ "$1" != 'ALL' ]; then - JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)") +if [ "$TARGET" != 'ALL' ]; then + JAILS=$(jls name | grep -w "${1}") fi for _jail in ${JAILS}; do echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}" - jexec -l ${_jail} /usr/sbin/service $2 + jexec -l ${_jail} /usr/sbin/service $@ echo done diff --git a/usr/local/share/bastille/start.sh b/usr/local/share/bastille/start.sh index 957cd20e..ad14b624 100644 --- a/usr/local/share/bastille/start.sh +++ b/usr/local/share/bastille/start.sh @@ -47,19 +47,26 @@ if [ $# -gt 1 ] || [ $# -lt 1 ]; then usage fi -if [ "$1" = 'ALL' ]; then - JAILS=$(/usr/local/bin/bastille list jails) +TARGET="${1}" + +if [ "$TARGET" = 'ALL' ]; then + JAILS=$(bastille list jails) fi -if [ "$1" != 'ALL' ]; then - JAILS=$(/usr/local/bin/bastille list jails | grep -w "$1") +if [ "$TARGET" != 'ALL' ]; then + JAILS=$(bastille list jails | grep -w "$TARGET") fi for _jail in ${JAILS}; do - if [ $(jls name | grep ${_jail}) ]; then + ## test if running + if [ $(jls name | grep -w ${_jail}) ]; then echo -e "${COLOR_RED}[${_jail}]: Already started.${COLOR_RESET}" - elif [ ! $(jls name | grep ${_jail}) ]; then + + ## test if not running + elif [ ! $(jls name | grep -w ${_jail}) ]; then echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}" jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -c ${_jail} + + ## update ${bastille_jail_loopback}:network with added/removed addresses if [ ! -z ${bastille_jail_loopback} ]; then pfctl -f /etc/pf.conf fi diff --git a/usr/local/share/bastille/stop.sh b/usr/local/share/bastille/stop.sh index cd47e1e0..4334f346 100644 --- a/usr/local/share/bastille/stop.sh +++ b/usr/local/share/bastille/stop.sh @@ -47,18 +47,29 @@ if [ $# -gt 1 ] || [ $# -lt 1 ]; then usage fi -if [ "$1" = 'ALL' ]; then +TARGET="${1}" + +if [ "${TARGET}" = 'ALL' ]; then JAILS=$(jls name) fi -if [ "$1" != 'ALL' ]; then - JAILS=$(jls name | grep -w "$1") +if [ "${TARGET}" != 'ALL' ]; then + JAILS=$(jls name | grep -w "${TARGET}") fi for _jail in ${JAILS}; do - echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}" - jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -r ${_jail} - if [ ! -z ${bastille_jail_loopback} ]; then - pfctl -f /etc/pf.conf + ## test if not running + if [ ! $(jls name | grep -w "${_jail}") ]; then + echo -e "${COLOR_RED}[${_jail}]: Not started.${COLOR_RESET}" + + ## test if running + elif [ $(jls name | grep -w "${_jail}") ]; then + echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}" + jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -r ${_jail} + + ## update ${bastille_jail_loopback}:network with added/removed addresses + if [ ! -z ${bastille_jail_loopback} ]; then + pfctl -f /etc/pf.conf + fi fi echo done diff --git a/usr/local/share/bastille/sysrc.sh b/usr/local/share/bastille/sysrc.sh index 20838448..7e838363 100644 --- a/usr/local/share/bastille/sysrc.sh +++ b/usr/local/share/bastille/sysrc.sh @@ -42,20 +42,23 @@ help|-h|--help) ;; esac -if [ $# -gt 2 ] || [ $# -lt 2 ]; then +if [ $# -lt 2 ]; then usage fi -if [ "$1" = 'ALL' ]; then +TARGET="${1}" +shift + +if [ "$TARGET" = 'ALL' ]; then JAILS=$(jls name) fi -if [ "$1" != 'ALL' ]; then - JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)") +if [ "$TARGET" != 'ALL' ]; then + JAILS=$(jls name | grep -w "${1}") fi for _jail in ${JAILS}; do echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}" - jexec -l ${_jail} /usr/sbin/sysrc $2 + jexec -l ${_jail} /usr/sbin/sysrc $@ echo -e "${COLOR_RESET}" done diff --git a/usr/local/share/bastille/template.sh b/usr/local/share/bastille/template.sh index 8b8b8ce4..103957df 100644 --- a/usr/local/share/bastille/template.sh +++ b/usr/local/share/bastille/template.sh @@ -32,7 +32,7 @@ . /usr/local/etc/bastille/bastille.conf usage() { - echo -e "${COLOR_RED}Usage: bastille template [ALL|glob] template.${COLOR_RESET}" + echo -e "${COLOR_RED}Usage: bastille template TARGET template/path.${COLOR_RESET}" exit 1 } @@ -47,15 +47,23 @@ if [ $# -gt 2 ] || [ $# -lt 2 ]; then usage fi -if [ "$1" = 'ALL' ]; then +TARGET="${1}" + +if [ "${TARGET}" = 'ALL' ]; then JAILS=$(jls name) fi -if [ "$1" != 'ALL' ]; then - JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)") +if [ "${TARGET}" != 'ALL' ]; then + JAILS=$(jls name | grep -w "${TARGET}") +fi + +TEMPLATE="${2}" + +if [ ! -d "${bastille_templatesdir}"/"${TEMPLATE}" ]; then + echo -e "${COLOR_RED}${TEMPLATE} not found.${COLOR_RESET}" + exit 1 fi ## global variables -TEMPLATE=$2 bastille_template=${bastille_templatesdir}/${TEMPLATE} bastille_template_TARGET=${bastille_template}/TARGET bastille_template_INCLUDE=${bastille_template}/INCLUDE @@ -76,7 +84,7 @@ for _jail in ${JAILS}; do ## TARGET if [ -s "${bastille_template_TARGET}" ]; then - if [ $(grep -E "(^|\b)\!${_jail}($|\b)" ${bastille_template_TARGET}) ]; then + if [ $(grep -w "${_jail}" ${bastille_template_TARGET}) ]; then echo -e "${COLOR_GREEN}TARGET: !${_jail}.${COLOR_RESET}" echo continue @@ -90,7 +98,7 @@ for _jail in ${JAILS}; do ## INCLUDE if [ -s "${bastille_template_INCLUDE}" ]; then - echo -e "${COLOR_GREEN}Detected INCLUDE.${COLOR_RESET}" + echo -e "${COLOR_GREEN}[${_jail}]:INCLUDE -- START${COLOR_RESET}" while read _include; do echo echo -e "${COLOR_GREEN}INCLUDE: ${_include}${COLOR_RESET}" @@ -103,29 +111,35 @@ for _jail in ${JAILS}; do BASTILLE_TEMPLATE_REPO=$(echo "${_include}" | awk -F / '{ print $5}') bastille template ${_jail} ${BASTILLE_TEMPLATE_PROJECT}/${BASTILLE_TEMPLATE_REPO} done < "${bastille_template_INCLUDE}" + echo -e "${COLOR_GREEN}[${_jail}]:INCLUDE -- END${COLOR_RESET}" + echo fi ## PRE if [ -s "${bastille_template_PRE}" ]; then - echo -e "${COLOR_GREEN}Executing PRE-command(s).${COLOR_RESET}" + echo -e "${COLOR_GREEN}[${_jail}]:PRE -- START${COLOR_RESET}" jexec -l ${_jail} /bin/sh < "${bastille_template_PRE}" || exit 1 + echo -e "${COLOR_GREEN}[${_jail}]:PRE -- END${COLOR_RESET}" + echo fi ## CONFIG / OVERLAY if [ -s "${bastille_template_OVERLAY}" ]; then - echo -e "${COLOR_GREEN}Copying files...${COLOR_RESET}" + echo -e "${COLOR_GREEN}[${_jail}]:OVERLAY -- START${COLOR_RESET}" while read _dir; do - cp -a "${bastille_template}/${_dir}" "${bastille_jail_path}" || exit 1 + cp -av "${bastille_template}/${_dir}" "${bastille_jail_path}" || exit 1 done < ${bastille_template_OVERLAY} - echo -e "${COLOR_GREEN}Copy complete.${COLOR_RESET}" + echo -e "${COLOR_GREEN}[${_jail}]:OVERLAY -- END${COLOR_RESET}" + echo fi if [ -s "${bastille_template}/CONFIG" ]; then echo -e "${COLOR_YELLOW}CONFIG deprecated; rename to OVERLAY.${COLOR_RESET}" - echo -e "${COLOR_GREEN}Copying files...${COLOR_RESET}" + echo -e "${COLOR_GREEN}[${_jail}]:CONFIG -- START${COLOR_RESET}" while read _dir; do - cp -a "${bastille_template}/${_dir}" "${bastille_jail_path}" || exit 1 + cp -av "${bastille_template}/${_dir}" "${bastille_jail_path}" || exit 1 done < ${bastille_template}/CONFIG - echo -e "${COLOR_GREEN}Copy complete.${COLOR_RESET}" + echo -e "${COLOR_GREEN}[${_jail}]:CONFIG -- END${COLOR_RESET}" + echo fi ## FSTAB @@ -144,33 +158,42 @@ for _jail in ${JAILS}; do ## PKG (bootstrap + pkg) if [ -s "${bastille_template_PKG}" ]; then - echo -e "${COLOR_GREEN}Installing packages.${COLOR_RESET}" + echo -e "${COLOR_GREEN}[${_jail}]:PKG -- START${COLOR_RESET}" jexec -l "${_jail}" env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg bootstrap || exit 1 - jexec -l "${_jail}" env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg audit -F || exit 1 + jexec -l "${_jail}" env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg audit -F jexec -l "${_jail}" env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg install $(cat ${bastille_template_PKG}) || exit 1 + echo -e "${COLOR_GREEN}[${_jail}]:PKG -- END${COLOR_RESET}" + echo fi ## SYSRC if [ -s "${bastille_template_SYSRC}" ]; then - echo -e "${COLOR_GREEN}Updating services.${COLOR_RESET}" + echo -e "${COLOR_GREEN}[${_jail}]:SYSRC -- START${COLOR_RESET}" while read _sysrc; do jexec -l ${_jail} /usr/sbin/sysrc "${_sysrc}" || exit 1 done < "${bastille_template_SYSRC}" + echo -e "${COLOR_GREEN}[${_jail}]:SYSRC -- END${COLOR_RESET}" + echo fi ## SERVICE if [ -s "${bastille_template_SERVICE}" ]; then - echo -e "${COLOR_GREEN}Managing services.${COLOR_RESET}" + echo -e "${COLOR_GREEN}[${_jail}]:SERVICE -- START${COLOR_RESET}" while read _service; do jexec -l ${_jail} /usr/sbin/service ${_service} || exit 1 done < "${bastille_template_SERVICE}" + echo -e "${COLOR_GREEN}[${_jail}]:SERVICE -- END${COLOR_RESET}" + echo fi ## CMD if [ -s "${bastille_template_CMD}" ]; then - echo -e "${COLOR_GREEN}Executing final command(s).${COLOR_RESET}" + echo -e "${COLOR_GREEN}[${_jail}]:CMD -- START${COLOR_RESET}" jexec -l ${_jail} /bin/sh < "${bastille_template_CMD}" || exit 1 + echo -e "${COLOR_GREEN}[${_jail}]:CMD -- END${COLOR_RESET}" + echo fi + echo -e "${COLOR_GREEN}Template Complete.${COLOR_RESET}" echo done diff --git a/usr/local/share/bastille/top.sh b/usr/local/share/bastille/top.sh index 5e630848..7e016a94 100644 --- a/usr/local/share/bastille/top.sh +++ b/usr/local/share/bastille/top.sh @@ -46,12 +46,14 @@ if [ $# -gt 1 ] || [ $# -lt 1 ]; then usage fi -if [ "$1" = 'ALL' ]; then +TARGET="${1}" + +if [ "$TARGET" = 'ALL' ]; then JAILS=$(jls name) fi -if [ "$1" != 'ALL' ]; then - JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)") +if [ "$TARGET" != 'ALL' ]; then + JAILS=$(jls name | grep -w "${1}") fi for _jail in ${JAILS}; do diff --git a/usr/local/share/bastille/zfs.sh b/usr/local/share/bastille/zfs.sh index 456bd94c..bdc137b8 100644 --- a/usr/local/share/bastille/zfs.sh +++ b/usr/local/share/bastille/zfs.sh @@ -87,16 +87,18 @@ if [ -z "${bastille_zfs_zpool}" ]; then exit 1 fi -if [ $# -gt 3 ] || [ $# -lt 2 ]; then +if [ $# -lt 2 ]; then usage fi -if [ "$1" = 'ALL' ]; then +TARGET="${1}" + +if [ "$TARGET" = 'ALL' ]; then JAILS=$(jls name) fi -if [ "$1" != 'ALL' ]; then - JAILS=$(jls name | grep -E "(^|\b)${1}($|\b)") +if [ "$TARGET" != 'ALL' ]; then + JAILS=$(jls name | grep -w "${1}") fi case "$2" in