From 6e850785a207e6f34ab43f2461dc8c328c35ad0d Mon Sep 17 00:00:00 2001 From: cynix Date: Mon, 30 Mar 2020 08:41:33 +0000 Subject: [PATCH 1/2] Fix empty interface name when creating the first VNET jail. Fixes #170. --- usr/local/share/bastille/create.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/usr/local/share/bastille/create.sh b/usr/local/share/bastille/create.sh index 6a19acf8..82f01d83 100644 --- a/usr/local/share/bastille/create.sh +++ b/usr/local/share/bastille/create.sh @@ -147,14 +147,16 @@ generate_vnet_jail_conf() { local list_jails_num=$(bastille list jails | wc -l | awk '{print $1}') local num_range=$(expr "${list_jails_num}" + 1) jail_list=$(bastille list jail) - for _num in $(seq 0 "${num_range}"); do - if [ -n "${jail_list}" ]; then + if [ -n "${jail_list}" ]; then + for _num in $(seq 0 "${num_range}"); do if ! grep -q "e0b_bastille${_num}" "${bastille_jailsdir}"/*/jail.conf; then uniq_epair="bastille${_num}" break fi - fi - done + done + else + uniq_epair="bastille0" + fi ## generate config cat << EOF > "${bastille_jail_conf}" From ced148bcc729dc480f0a365a9bdf7e729db896ea Mon Sep 17 00:00:00 2001 From: cynix Date: Mon, 30 Mar 2020 08:48:04 +0000 Subject: [PATCH 2/2] Clean up code --- usr/local/share/bastille/create.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr/local/share/bastille/create.sh b/usr/local/share/bastille/create.sh index 82f01d83..7df5a11f 100644 --- a/usr/local/share/bastille/create.sh +++ b/usr/local/share/bastille/create.sh @@ -144,10 +144,10 @@ generate_vnet_jail_conf() { ## determine number of containers + 1 ## iterate num and grep all jail configs ## define uniq_epair - local list_jails_num=$(bastille list jails | wc -l | awk '{print $1}') - local num_range=$(expr "${list_jails_num}" + 1) - jail_list=$(bastille list jail) + local jail_list=$(bastille list jails) if [ -n "${jail_list}" ]; then + local list_jails_num=$(echo "${jail_list}" | wc -l | awk '{print $1}') + local num_range=$(expr "${list_jails_num}" + 1) for _num in $(seq 0 "${num_range}"); do if ! grep -q "e0b_bastille${_num}" "${bastille_jailsdir}"/*/jail.conf; then uniq_epair="bastille${_num}"