diff --git a/usr/local/share/bastille/common.sh b/usr/local/share/bastille/common.sh index fd62d6e2..c518a97f 100644 --- a/usr/local/share/bastille/common.sh +++ b/usr/local/share/bastille/common.sh @@ -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 @@ -196,7 +208,7 @@ set_target_single() { exit 1 fi fi - TARGET="${_TARGET}" + TARGET="${_TARGET} " JAILS="${_TARGET}" export TARGET export JAILS @@ -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 } @@ -365,5 +385,4 @@ checkyesno() { return 1 ;; esac -} - +} \ No newline at end of file diff --git a/usr/local/share/bastille/destroy.sh b/usr/local/share/bastille/destroy.sh index b18a670a..4e655fc6 100644 --- a/usr/local/share/bastille/destroy.sh +++ b/usr/local/share/bastille/destroy.sh @@ -298,7 +298,7 @@ case "${TARGET}" in ;; *) ## just destroy a jail - set_target "${TARGET}" + set_target "${TARGET}" "reverse" destroy_jail "${JAILS}" ;; esac diff --git a/usr/local/share/bastille/list.sh b/usr/local/share/bastille/list.sh index a59a0eb3..255ed5ed 100644 --- a/usr/local/share/bastille/list.sh +++ b/usr/local/share/bastille/list.sh @@ -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. @@ -346,4 +352,4 @@ if [ "$#" -gt 0 ]; then fi ;; esac -fi +fi \ No newline at end of file diff --git a/usr/local/share/bastille/stop.sh b/usr/local/share/bastille/stop.sh index 41441290..29e1bcfa 100644 --- a/usr/local/share/bastille/stop.sh +++ b/usr/local/share/bastille/stop.sh @@ -90,7 +90,7 @@ fi TARGET="${1}" bastille_root_check -set_target "${TARGET}" +set_target "${TARGET}" "reverse" for _jail in ${JAILS}; do