epair: Use full list

This commit is contained in:
tschettervictor
2025-04-16 17:22:51 -06:00
parent 353a63eef8
commit dd2a56af6d
3 changed files with 7 additions and 6 deletions

View File

@@ -203,7 +203,7 @@ update_jailconf_vnet() {
if echo ${_if} | grep -Eoq 'epair[0-9]+'; then if echo ${_if} | grep -Eoq 'epair[0-9]+'; then
# Update bridged VNET config # Update bridged VNET config
for _num in $(seq 0 "${_epair_num_range}"); do for _num in $(seq 0 "${_epair_num_range}"); do
if ! grep -Eoq "(bastille${_num}|epair${_num})" ${bastille_jailsdir}/*/jail.conf && ! ifconfig -g epair | grep -Eosq "(e${_num}a|epair${_num}a|bastille${_num})"; then if ! echo "${_epair_list}" | grep -osq "${_num}" && ! grep -Eoq "(bastille${_num}|epair${_num})" ${bastille_jailsdir}/*/jail.conf && ! ifconfig -g epair | grep -Eosq "(e${_num}a|epair${_num}a|bastille${_num})"; then
# Generate new epair name # Generate new epair name
if [ "$(echo -n "e${_num}a_${NEWNAME}" | awk '{print length}')" -lt 16 ]; then if [ "$(echo -n "e${_num}a_${NEWNAME}" | awk '{print length}')" -lt 16 ]; then
local _new_host_epair="e${_num}a_${NEWNAME}" local _new_host_epair="e${_num}a_${NEWNAME}"
@@ -272,7 +272,7 @@ update_jailconf_vnet() {
elif echo ${_if} | grep -Eoq 'bastille[0-9]+'; then elif echo ${_if} | grep -Eoq 'bastille[0-9]+'; then
# Update VNET config # Update VNET config
for _num in $(seq 0 "${_epair_num_range}"); do for _num in $(seq 0 "${_epair_num_range}"); do
if ! grep -Eoq "(bastille${_num}|epair${_num})" ${bastille_jailsdir}/*/jail.conf && ! ifconfig -g epair | grep -Eosq "(e${_num}a|epair${_num}a|bastille${_num})"; then if ! echo "${_epair_list}" | grep -osq "${_num}" && ! grep -Eoq "(bastille${_num}|epair${_num})" ${bastille_jailsdir}/*/jail.conf && ! ifconfig -g epair | grep -Eosq "(e${_num}a|epair${_num}a|bastille${_num})"; then
# Update jail.conf epair name # Update jail.conf epair name
local uniq_epair="bastille${_num}" local uniq_epair="bastille${_num}"
local _jail_vnet="$(grep ${_if} "${_rc_conf}" | grep -Eo -m 1 "vnet[0-9]+")" local _jail_vnet="$(grep ${_if} "${_rc_conf}" | grep -Eo -m 1 "vnet[0-9]+")"

View File

@@ -121,9 +121,10 @@ check_target_is_stopped() {
get_epair_count() { get_epair_count() {
for _config in /usr/local/etc/bastille/*.conf; do for _config in /usr/local/etc/bastille/*.conf; do
local bastille_jailsdir="$(sysrc -f "${_config}" -n bastille_jailsdir)" 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)" _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 done
_epair_count=$(printf '%s' "${_epair_list}" | wc -l | awk '{print $1}') _epair_count=$(printf '%s' "${_epair_list}" | wc -l | awk '{print $1}')
export _epair_list
export _epair_count export _epair_count
} }
@@ -292,7 +293,7 @@ generate_vnet_jail_netblock() {
if [ -n "${use_unique_bridge}" ]; then if [ -n "${use_unique_bridge}" ]; then
if [ "${_epair_count}" -gt 0 ]; then if [ "${_epair_count}" -gt 0 ]; then
for _num in $(seq 0 "${_epair_num_range}"); do for _num in $(seq 0 "${_epair_num_range}"); do
if ! grep -Eosq "(bastille${_num}|epair${_num})" ${bastille_jailsdir}/*/jail.conf && ! ifconfig -g epair | grep -Eosq "(e${_num}a|epair${_num}a|bastille${_num})"; then if ! echo "${_epair_list}" | grep -osq "${_num}" && ! grep -Eosq "(bastille${_num}|epair${_num})" ${bastille_jailsdir}/*/jail.conf && ! ifconfig -g epair | grep -Eosq "(e${_num}a|epair${_num}a|bastille${_num})"; then
if [ "$(echo -n "e${_num}a_${jail_name}" | awk '{print length}')" -lt 16 ]; then if [ "$(echo -n "e${_num}a_${jail_name}" | awk '{print length}')" -lt 16 ]; then
local host_epair=e${_num}a_${jail_name} local host_epair=e${_num}a_${jail_name}
local jail_epair=e${_num}b_${jail_name} local jail_epair=e${_num}b_${jail_name}
@@ -317,7 +318,7 @@ generate_vnet_jail_netblock() {
else else
if [ "${_epair_count}" -gt 0 ]; then if [ "${_epair_count}" -gt 0 ]; then
for _num in $(seq 0 "${_epair_num_range}"); do for _num in $(seq 0 "${_epair_num_range}"); do
if ! grep -Eosq "(bastille${_num}|epair${_num})" ${bastille_jailsdir}/*/jail.conf && ! ifconfig -g epair | grep -Eosq "(e${_num}a|epair${_num}a|bastille${_num})"; then if ! echo "${_epair_list}" | grep -osq "${_num}" && ! grep -Eosq "(bastille${_num}|epair${_num})" ${bastille_jailsdir}/*/jail.conf && ! ifconfig -g epair | grep -Eosq "(e${_num}a|epair${_num}a|bastille${_num})"; then
local uniq_epair="bastille${_num}" local uniq_epair="bastille${_num}"
break break
fi fi

View File

@@ -239,7 +239,7 @@ add_interface() {
if [ "${BRIDGE}" -eq 1 ]; then if [ "${BRIDGE}" -eq 1 ]; then
if [ "${_epair_count}" -gt 0 ]; then if [ "${_epair_count}" -gt 0 ]; then
for _num in $(seq 0 "${_epair_num_range}"); do for _num in $(seq 0 "${_epair_num_range}"); do
if ! grep -Eosq "(bastille${_num}|epair${_num})" ${bastille_jailsdir}/*/jail.conf && ! ifconfig -g epair | grep -Eosq "(e${_num}a|epair${_num}a|bastille${_num})"; then if ! echo "${_epair_list}" | grep -osq "${_num}" && ! grep -Eosq "(bastille${_num}|epair${_num})" ${bastille_jailsdir}/*/jail.conf && ! ifconfig -g epair | grep -Eosq "(e${_num}a|epair${_num}a|bastille${_num})"; then
if [ "$(echo -n "e${_num}a_${jail_name}" | awk '{print length}')" -lt 16 ]; then if [ "$(echo -n "e${_num}a_${jail_name}" | awk '{print length}')" -lt 16 ]; then
local host_epair=e${_num}a_${_jailname} local host_epair=e${_num}a_${_jailname}
local jail_epair=e${_num}b_${_jailname} local jail_epair=e${_num}b_${_jailname}