priority: Use priority list for all comm

This commit is contained in:
tschettervictor
2025-03-17 19:54:34 -06:00
parent aad1158146
commit b843b2c100
4 changed files with 34 additions and 9 deletions

View File

@@ -146,6 +146,11 @@ jail_autocomplete() {
set_target() {
local _TARGET=${1}
if [ "${2}" = "reverse" ]; then
local _order="${2}"
else
local _order="forward"
fi
JAILS=""
TARGET=""
if [ "${_TARGET}" = ALL ] || [ "${_TARGET}" = all ]; then
@@ -170,6 +175,13 @@ set_target() {
TARGET="${TARGET} ${_jail}"
JAILS="${JAILS} ${_jail}"
done
if [ "${_order}" = "forward" ]; then
TARGET="$(bastille list priority | sort -k2 -n | awk '{print $1}')
JAILS="$(bastille list priority | sort -k2 -n | awk '{print $1}')
elif [ "${_order}" = "reverse" ]; then
TARGET="$(bastille list priority "${TARGET}" | sort -k2 -nr | awk '{print $1}')
JAILS="$(bastille list priority "${TARGET}" | sort -k2 -nr | awk '{print $1}')
fi
export TARGET
export JAILS
fi
@@ -210,6 +222,14 @@ target_all_jails() {
JAILS="${JAILS} ${_jail}"
fi
done
if [ "${_order}" = "forward" ]; then
TARGET="$(bastille list priority | sort -k2 -n | awk '{print $1}')"
JAILS="$(bastille list priority | sort -k2 -n | awk '{print $1}')"
elif [ "${_order}" = "reverse" ]; then
TARGET="$(bastille list priority | sort -k2 -nr | awk '{print $1}')"
JAILS="$(bastille list priority | sort -k2 -nr | awk '{print $1}')"
fi
export TARGET
export JAILS
}
@@ -366,4 +386,3 @@ checkyesno() {
;;
esac
}

View File

@@ -298,7 +298,7 @@ case "${TARGET}" in
;;
*)
## just destroy a jail
set_target "${TARGET}"
set_target "${TARGET}" "reverse"
destroy_jail "${JAILS}"
;;
esac

View File

@@ -243,9 +243,9 @@ list_ports(){
}
list_priority() {
local _jail_list="${1}"
if [ -d "${bastille_jailsdir}" ]; then
JAIL_LIST="$(bastille list jails)"
for _jail in ${JAIL_LIST}; do
for _jail in ${_jail_list}; do
if [ -f "${bastille_jailsdir}/${_jail}/boot.conf" ]; then
_priority="$(sysrc -f ${bastille_jailsdir}/${_jail}/boot.conf -n priority)"
echo "${_jail} ${_priority}"
@@ -333,7 +333,13 @@ if [ "$#" -gt 0 ]; then
exit 0
;;
priorities|priority|prio)
list_priority
if [ -z "${2}" ]; then
_jail_list="$(list_jail)"
list_priority "${_jail_list}"
else
_jail_list="${2}"
list_priority "${_jail_list}"
fi
;;
*)
# Check if we want to query all info for a specific jail instead.

View File

@@ -90,7 +90,7 @@ fi
TARGET="${1}"
bastille_root_check
set_target "${TARGET}"
set_target "${TARGET}" "reverse"
for _jail in ${JAILS}; do