From 0fe4bec89fab0a25a2bf68d6d53435aeccbed4c6 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Wed, 16 Apr 2025 15:57:07 -0600 Subject: [PATCH] common: Add function to count epairs --- usr/local/share/bastille/common.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/usr/local/share/bastille/common.sh b/usr/local/share/bastille/common.sh index 0edf2eae..deeff781 100644 --- a/usr/local/share/bastille/common.sh +++ b/usr/local/share/bastille/common.sh @@ -118,6 +118,15 @@ check_target_is_stopped() { fi } +get_epair_count() { + for _config in /usr/local/etc/bastille/*.conf; do + local bastille_jailsdir="$(sysrc -f "${_config}" -n bastille_jailsdir)" + local _epair_list="$(printf '%s\n' $( (grep -Eos '(e[0-9]+b|bastille[0-9]+)' ${bastille_jailsdir}/*/jail.conf; ifconfig -g epair) | grep -Eo "[0-9]+") ${_epair_list} | sort -u)" + done + _epair_count="$(echo ${_epair_list} | wc -l | awk '{print $1}')" + export _epair_count +} + get_jail_name() { local _JID="${1}" local _jailname="$(jls -j ${_JID} name 2>/dev/null)"