fix listing jail priority

This commit is contained in:
tschettervictor
2025-03-19 10:24:50 -06:00
parent 601d120d76
commit eaacab6e7e
2 changed files with 24 additions and 29 deletions

View File

@@ -144,6 +144,22 @@ jail_autocomplete() {
fi fi
} }
list_jail_priority() {
local _jail_list="${1}"
if [ -d "${bastille_jailsdir}" ]; then
for _jail in ${_jail_list}; do
local _boot_file=${bastille_jailsdir}/${_jail}/boot.conf
# Set defaults if boot file does not exist
if [ ! -f ${_boot_file} ]; then
sysrc -f ${_boot_file} boot=on
sysrc -f ${_boot_file} priority=99
fi
_priority="$(sysrc -f ${bastille_jailsdir}/${_jail}/boot.conf -n priority)"
echo "${_jail} ${_priority}"
done
fi
}
set_target() { set_target() {
local _TARGET=${1} local _TARGET=${1}
if [ "${2}" = "reverse" ]; then if [ "${2}" = "reverse" ]; then
@@ -176,11 +192,11 @@ set_target() {
JAILS="${JAILS} ${_jail}" JAILS="${JAILS} ${_jail}"
done done
if [ "${_order}" = "forward" ]; then if [ "${_order}" = "forward" ]; then
TARGET="$(bastille list priority "${TARGET}" | sort -k2 -n | awk '{print $1}')" TARGET="$(list_jail_priority "${TARGET}" | sort -k2 -n | awk '{print $1}')"
JAILS="$(bastille list priority "${TARGET}" | sort -k2 -n | awk '{print $1}')" JAILS="$(list_jail_priority "${TARGET}" | sort -k2 -n | awk '{print $1}')"
elif [ "${_order}" = "reverse" ]; then elif [ "${_order}" = "reverse" ]; then
TARGET="$(bastille list priority "${TARGET}" | sort -k2 -nr | awk '{print $1}')" TARGET="$(list_jail_priority "${TARGET}" | sort -k2 -nr | awk '{print $1}')"
JAILS="$(bastille list priority "${TARGET}" | sort -k2 -nr | awk '{print $1}')" JAILS="$(list_jail_priority "${TARGET}" | sort -k2 -nr | awk '{print $1}')"
fi fi
export TARGET export TARGET
export JAILS export JAILS
@@ -223,11 +239,11 @@ target_all_jails() {
fi fi
done done
if [ "${_order}" = "forward" ]; then if [ "${_order}" = "forward" ]; then
TARGET="$(bastille list priority | sort -k2 -n | awk '{print $1}')" TARGET="$(list_jail_priority | sort -k2 -n | awk '{print $1}')"
JAILS="$(bastille list priority | sort -k2 -n | awk '{print $1}')" JAILS="$(list_jail_priority | sort -k2 -n | awk '{print $1}')"
elif [ "${_order}" = "reverse" ]; then elif [ "${_order}" = "reverse" ]; then
TARGET="$(bastille list priority | sort -k2 -nr | awk '{print $1}')" TARGET="$(list_jail_priority | sort -k2 -nr | awk '{print $1}')"
JAILS="$(bastille list priority | sort -k2 -nr | awk '{print $1}')" JAILS="$(list_jail_priority | sort -k2 -nr | awk '{print $1}')"
fi fi
export TARGET export TARGET
export JAILS export JAILS

View File

@@ -242,18 +242,6 @@ list_ports(){
fi fi
} }
list_priority() {
local _jail_list="${1}"
if [ -d "${bastille_jailsdir}" ]; then
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}"
fi
done
fi
}
bastille_root_check bastille_root_check
if [ "$#" -eq 0 ]; then if [ "$#" -eq 0 ]; then
@@ -332,15 +320,6 @@ if [ "$#" -gt 0 ]; then
list_import list_import
exit 0 exit 0
;; ;;
priorities|priority|prio)
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.
if [ -f "${bastille_jailsdir}/${1}/jail.conf" ]; then if [ -f "${bastille_jailsdir}/${1}/jail.conf" ]; then