rc: properly handle priority

This commit is contained in:
tschettervictor
2025-08-03 19:51:17 -06:00
committed by GitHub
parent bebeed7654
commit 985286e74f

View File

@@ -37,28 +37,37 @@ stop_cmd="bastille_stop"
restart_cmd="bastille_restart" restart_cmd="bastille_restart"
list_jails() { list_jails() {
local _jailsdir local _jailsdir=$(. $bastille_conf; echo $bastille_jailsdir)
_jailsdir=$(. $bastille_conf; echo $bastille_jailsdir) local _jail_list=$(find ${_jailsdir}/* -mindepth 1 -maxdepth 1 -type f -name jail.conf | xargs -n1 dirname | xargs -n1 basename)
bastille_jail_list=$(find ${_jailsdir}/* -mindepth 1 -maxdepth 1 -type f -name jail.conf \ for _jail in ${_jail_list}; do
| xargs -n1 dirname \ _priority="$(sysrc -f ${_jailsdir}/${_jail}/settings.conf -n priority)"
| xargs -n1 basename) echo "${_jail} ${_priority}"
done
} }
bastille_start() sort_jails() {
{ local _order="${1}"
list_jails if [ "${_order}" = "forward" ]; then
bastille_jail_list="$(list_jails | sort -k2 -n | awk '{print $1}')"
elif [ "${_order}" = "reverse" ]; then
bastille_jail_list="$(list_jails | sort -k2 -nr | awk '{print $1}')"
else
echo "[ERROR]: Fatal error, could not get jail list."
fi
}
bastille_start() {
sort_jails "forward"
echo "${bastille_jail_list}" | xargs -P ${bastille_parallel_limit} -I JAIL ${command} start --boot --delay ${bastille_startup_delay} JAIL echo "${bastille_jail_list}" | xargs -P ${bastille_parallel_limit} -I JAIL ${command} start --boot --delay ${bastille_startup_delay} JAIL
} }
bastille_stop() bastille_stop() {
{ sort_jails "reverse"
list_jails
echo "${bastille_jail_list}" | xargs -P ${bastille_parallel_limit} -I JAIL ${command} stop JAIL echo "${bastille_jail_list}" | xargs -P ${bastille_parallel_limit} -I JAIL ${command} stop JAIL
} }
bastille_restart() bastille_restart() {
{ sort_jails "forward"
list_jails
echo "${bastille_jail_list}" | xargs -P ${bastille_parallel_limit} -I JAIL ${command} restart --boot --delay ${bastille_startup_delay} JAIL echo "${bastille_jail_list}" | xargs -P ${bastille_parallel_limit} -I JAIL ${command} restart --boot --delay ${bastille_startup_delay} JAIL
} }