diff --git a/usr/local/share/bastille/setup.sh b/usr/local/share/bastille/setup.sh index f2efe8c1..b18e2518 100644 --- a/usr/local/share/bastille/setup.sh +++ b/usr/local/share/bastille/setup.sh @@ -87,6 +87,7 @@ if [ "$#" -gt 2 ]; then fi OPT_CONFIG="${1}" +OPT_ARG="${2}" bastille_root_check @@ -290,29 +291,35 @@ configure_storage() { if mount | grep "zfs" >/dev/null 2>/dev/null; then + _auto_zpool="${1}" + if [ ! "$(kldstat -m zfs)" ]; then info "\nZFS module not loaded; skipping..." elif sysrc -f ${BASTILLE_CONFIG} -n bastille_zfs_enable | grep -Eoq "([Y|y][E|e][S|s])"; then info "\nZFS has already been configured!" else - _zpool_list=$(zpool list | grep -v NAME | awk '{print $1}') - _zpool_count=0 - if [ "$(zpool list | grep -v NAME | awk '{print $1}' | wc -l)" -eq 1 ]; then - _bastille_zpool="${_zpool_list}" - else - info "\nMultiple zpools detected:" - for _zpool in ${_zpool_list}; do - echo "[${_zpool_count}] ${_zpool}" - _zpool_num="${_zpool_num} [${_zpool_count}]${_zpool}" - _zpool_count=$(expr ${_zpool_count} + 1) - done - # shellcheck disable=SC3045 - read -p "Please select the zpool for Bastille to use: " _zpool_choice - if ! echo "${_zpool_choice}" | grep -Eq "^[0-9]+$"; then - error_exit "Invalid input number, aborting!" + if [ -z "${_auto_zpool}" ]; then + _zpool_list=$(zpool list | grep -v NAME | awk '{print $1}') + _zpool_count=0 + if [ "$(zpool list | grep -v NAME | awk '{print $1}' | wc -l)" -eq 1 ]; then + _bastille_zpool="${_zpool_list}" else - _zpool_select=$(echo "${_zpool_num}" | grep -wo "\[${_zpool_choice}\][^ ]*" | sed 's/\[.*\]//g') + info "\nMultiple zpools detected:" + for _zpool in ${_zpool_list}; do + echo "[${_zpool_count}] ${_zpool}" + _zpool_num="${_zpool_num} [${_zpool_count}]${_zpool}" + _zpool_count=$(expr ${_zpool_count} + 1) + done + # shellcheck disable=SC3045 + read -p "Please select the zpool for Bastille to use: " _zpool_choice + if ! echo "${_zpool_choice}" | grep -Eq "^[0-9]+$"; then + error_exit "Invalid input number, aborting!" + else + _zpool_select=$(echo "${_zpool_num}" | grep -wo "\[${_zpool_choice}\][^ ]*" | sed 's/\[.*\]//g') + fi fi + else + _bastille_zpool="${_auto_zpool}" fi sysrc -f "${BASTILLE_CONFIG}" bastille_zfs_enable=YES sysrc -f "${BASTILLE_CONFIG}" bastille_zfs_zpool="${_bastille_zpool}" @@ -394,7 +401,7 @@ case "${OPT_CONFIG}" in read -p "Do you really want to continue setting up the shared interface? [y|n]:" _answer case "${_answer}" in [Yy]|[Yy][Ee][Ss]) - configure_shared_interface "${ARG}" + configure_shared_interface "${OPT_ARG}" ;; [Nn]|[Nn][Oo]) error_exit "Shared interface setup cancelled." @@ -406,7 +413,7 @@ case "${OPT_CONFIG}" in fi ;; storage) - configure_storage "${ARG}" + configure_storage "${OPT_ARG}" ;; vnet) configure_vnet @@ -416,7 +423,7 @@ case "${OPT_CONFIG}" in error_exit "[ERROR]: 'bridge' does not support [-y|--yes]." else configure_vnet - configure_bridge "${ARG}" + configure_bridge "${OPT_ARG}" fi ;; *)