From eebe8955140e73cfbd568cb4dab2ef35c7750455 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Wed, 16 Jul 2025 17:59:20 -0600 Subject: [PATCH 1/4] =?UTF-8?q?common:=20Add=20option=20to=20use=20?= =?UTF-8?q?=E2=80=9Ctags=E2=80=9D=20as=20TARGET?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/local/share/bastille/common.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr/local/share/bastille/common.sh b/usr/local/share/bastille/common.sh index 4b5da5c4..897a33ae 100644 --- a/usr/local/share/bastille/common.sh +++ b/usr/local/share/bastille/common.sh @@ -239,7 +239,9 @@ set_target() { target_all_jails else for _jail in ${_TARGET}; do - if [ ! -d "${bastille_jailsdir}/${_TARGET}" ] && echo "${_jail}" | grep -Eq '^[0-9]+$'; then + if grep -Eohw "${_jail}" "${bastille_jailsdir}/*/tags"; then + _jail="$(bastille tags ALL list ${_jail} | tr '\n' ' ')" + elif [ ! -d "${bastille_jailsdir}/${_TARGET}" ] && echo "${_jail}" | grep -Eq '^[0-9]+$'; then if get_jail_name "${_jail}" > /dev/null; then _jail="$(get_jail_name ${_jail})" else From 808d26190054a5e0832c3662f785095d369aae24 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Wed, 16 Jul 2025 18:03:35 -0600 Subject: [PATCH 2/4] docs: targetting: Add docs for using a tag as the TARGET --- docs/chapters/targeting.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/chapters/targeting.rst b/docs/chapters/targeting.rst index 3f01e419..dd4a5351 100644 --- a/docs/chapters/targeting.rst +++ b/docs/chapters/targeting.rst @@ -5,8 +5,11 @@ Bastille uses a ``subcommand TARGET ARGS`` syntax, meaning that each command requires a target. Targets are usually containers, but can also be releases. Targeting a container is done by providing the exact jail name, the JID of the -jail, or by typing the starting few characters of a jail. If more than one -matching jail will be found, you will see a message saying so. +jail, a tag, or by typing the starting few characters of a jail. If more than one +matching jail is found, you will see an error saying so. + +If you use a tag as the TARGET, Bastille will target any and all jail(s) that have +the tag assigned. Targeting a release is done by providing the exact release name. (Note: do not include the ``-pX`` point-release version.) From 3267a9a0c1882aacaf3ea5b0686b8a26ab22d1fb Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Wed, 16 Jul 2025 18:47:54 -0600 Subject: [PATCH 3/4] common: Do not target tags if jail exists with same name --- usr/local/share/bastille/common.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/usr/local/share/bastille/common.sh b/usr/local/share/bastille/common.sh index 897a33ae..01960720 100644 --- a/usr/local/share/bastille/common.sh +++ b/usr/local/share/bastille/common.sh @@ -239,9 +239,7 @@ set_target() { target_all_jails else for _jail in ${_TARGET}; do - if grep -Eohw "${_jail}" "${bastille_jailsdir}/*/tags"; then - _jail="$(bastille tags ALL list ${_jail} | tr '\n' ' ')" - elif [ ! -d "${bastille_jailsdir}/${_TARGET}" ] && echo "${_jail}" | grep -Eq '^[0-9]+$'; then + if [ ! -d "${bastille_jailsdir}/${_TARGET}" ] && echo "${_jail}" | grep -Eq '^[0-9]+$'; then if get_jail_name "${_jail}" > /dev/null; then _jail="$(get_jail_name ${_jail})" else @@ -251,7 +249,11 @@ set_target() { if jail_autocomplete "${_jail}" > /dev/null; then _jail="$(jail_autocomplete ${_jail})" elif [ $? -eq 2 ]; then - error_continue "Jail not found \"${_jail}\"" + if grep -Ehoqw ${_jail} ${bastille_jailsdir}/*/tags; then + _jail="$(grep -Eow ${_jail} ${bastille_jailsdir}/*/tags | awk -F"/tags" '{print $1}' | sed "s#${bastille_jailsdir}/##g" | tr '\n' ' ')" + else + error_continue "Jail not found \"${_jail}\"" + fi else echo exit 1 From e40bfdb86d589b6737e9f4764c742005f4d91d0c Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Wed, 16 Jul 2025 18:49:31 -0600 Subject: [PATCH 4/4] docs: targetting: Update for targetting jail when name matches tag --- docs/chapters/targeting.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/chapters/targeting.rst b/docs/chapters/targeting.rst index dd4a5351..cab9c518 100644 --- a/docs/chapters/targeting.rst +++ b/docs/chapters/targeting.rst @@ -9,7 +9,8 @@ jail, a tag, or by typing the starting few characters of a jail. If more than on matching jail is found, you will see an error saying so. If you use a tag as the TARGET, Bastille will target any and all jail(s) that have -the tag assigned. +the tag assigned. If you have a jail with the same name as the tag you are trying to +target, Bastille will target the jail, and not the tag. Targeting a release is done by providing the exact release name. (Note: do not include the ``-pX`` point-release version.)