diff --git a/usr/local/share/bastille/convert.sh b/usr/local/share/bastille/convert.sh index 67a406ad..85ff3887 100644 --- a/usr/local/share/bastille/convert.sh +++ b/usr/local/share/bastille/convert.sh @@ -265,19 +265,27 @@ if [ "$#" -eq 1 ]; then elif ! grep -qw ".bastille" "${bastille_jailsdir}/${TARGET}/fstab"; then error_exit "[ERROR]: ${TARGET} is not a thin container." fi - - # Make sure the user agree with the conversion - # Be interactive here since this cannot be easily undone - while :; do - warn "\n[WARNING]: Jail conversion from thin to thick can't be undone!\n" - # shellcheck disable=SC2162 + + # Ask if user is sure they want to convert the jail + # but only if AUTO_YES=0 + if [ "${AUTO_YES}" -ne 1 ]; then + warn "/n[WARNING]: Jail conversion from thin to thick can't be undone!\n" # shellcheck disable=SC3045 - read -p "Do you really wish to convert '${TARGET}' into a thick container? [y/N]:" yn - case ${yn} in - [Yy]) start_convert;; - [Nn]) exit 0;; + read -p "Are you sure you want to continue? [y|n]:" _answer + case "${_answer}" in + [Yy]|[Yy][Ee][Ss]) + start_convert + ;; + [Nn]|[Nn][Oo]) + error_exit "[ERROR]: Cancelled by user." + ;; + *) + error_exit "[ERROR]: Invalid input. Please answer 'y' or 'n'." + ;; esac - done + elif [ "${AUTO_YES}" -eq 1 ]; then + start_convert + fi elif [ "$#" -eq 2 ]; then @@ -292,4 +300,4 @@ elif [ "$#" -eq 2 ]; then convert_jail_to_release "${TARGET}" "${CONVERT_RELEASE}" else usage -fi \ No newline at end of file +fi