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() { set_target() {
local _TARGET=${1} local _TARGET=${1}
if [ "${2}" = "reverse" ]; then
local _order="${2}"
else
local _order="forward"
fi
JAILS="" JAILS=""
TARGET="" TARGET=""
if [ "${_TARGET}" = ALL ] || [ "${_TARGET}" = all ]; then if [ "${_TARGET}" = ALL ] || [ "${_TARGET}" = all ]; then
@@ -170,6 +175,13 @@ set_target() {
TARGET="${TARGET} ${_jail}" TARGET="${TARGET} ${_jail}"
JAILS="${JAILS} ${_jail}" JAILS="${JAILS} ${_jail}"
done 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 TARGET
export JAILS export JAILS
fi fi
@@ -196,7 +208,7 @@ set_target_single() {
exit 1 exit 1
fi fi
fi fi
TARGET="${_TARGET}" TARGET="${_TARGET} "
JAILS="${_TARGET}" JAILS="${_TARGET}"
export TARGET export TARGET
export JAILS export JAILS
@@ -210,6 +222,14 @@ target_all_jails() {
JAILS="${JAILS} ${_jail}" JAILS="${JAILS} ${_jail}"
fi fi
done 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 export JAILS
} }
@@ -365,5 +385,4 @@ checkyesno() {
return 1 return 1
;; ;;
esac esac
} }

View File

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

View File

@@ -243,9 +243,9 @@ list_ports(){
} }
list_priority() { list_priority() {
local _jail_list="${1}"
if [ -d "${bastille_jailsdir}" ]; then 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 if [ -f "${bastille_jailsdir}/${_jail}/boot.conf" ]; then
_priority="$(sysrc -f ${bastille_jailsdir}/${_jail}/boot.conf -n priority)" _priority="$(sysrc -f ${bastille_jailsdir}/${_jail}/boot.conf -n priority)"
echo "${_jail} ${_priority}" echo "${_jail} ${_priority}"
@@ -333,7 +333,13 @@ if [ "$#" -gt 0 ]; then
exit 0 exit 0
;; ;;
priorities|priority|prio) 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. # Check if we want to query all info for a specific jail instead.
@@ -346,4 +352,4 @@ if [ "$#" -gt 0 ]; then
fi fi
;; ;;
esac esac
fi fi

View File

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