mirror of
https://github.com/hackacad/bastille.git
synced 2026-01-06 04:34:19 +01:00
Local shellcheck pass using shellcheck version: 0.8.0
This commit is contained in:
@@ -103,7 +103,8 @@ config_backup() {
|
||||
config_network_reset() {
|
||||
# Restore bastille default network options.
|
||||
warn "Performing Network configuration reset, requested by the user..."
|
||||
read -p "$(warn "Do you really want to reset 'bastille' network configuration? [y/N]: ")" _response
|
||||
warn "Do you really want to reset 'bastille' network configuration? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
local VAR_ITEMS="bastille_network_loopback=bastille0 bastille_network_pf_ext_if=ext_if
|
||||
@@ -126,7 +127,8 @@ config_network_reset() {
|
||||
config_storage_reset() {
|
||||
# Restore bastille default ZFS storage options.
|
||||
warn "Performing ZFS configuration reset, requested by the user..."
|
||||
read -p "$(warn "Do you really want to reset 'bastille' ZFS configuration? [y/N]: ")" _response
|
||||
warn "Do you really want to reset 'bastille' ZFS configuration? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
local VAR_ITEMS="bastille_zfs_enable= bastille_zfs_zpool= bastille_zfs_prefix=bastille"
|
||||
@@ -155,7 +157,8 @@ config_restore_global() {
|
||||
# Be aware that if the sample configuration file is missing, we can generate a new one,
|
||||
# but that's highly unlikely to happen so will keep the code smaller here.
|
||||
warn "Performing Bastille default configuration restore, requested by the user..."
|
||||
read -p "$(warn "Do you really want to restore 'bastille' default configuration file and start over? [y/N]: ")" _response
|
||||
warn "Do you really want to restore 'bastille' default configuration file and start over? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
config_backup
|
||||
@@ -343,9 +346,8 @@ zfs_initial_activation() {
|
||||
# Just let the user interactively select the ZFS items manually from a list for the initial activation.
|
||||
# This should be performed before `bastille bootstrap` as we already know.
|
||||
info "Initial bastille ZFS activation helper invoked."
|
||||
#read -p "$(info "Would you like bastille attempt to auto-detect/activate ZFS for you?, (assuming a standard install was performed) [y/N]: ")" _response
|
||||
read -p "$(info "Would you like to configure the bastille ZFS options interactively? [y/N]: ")" _response
|
||||
|
||||
info "Would you like to configure the bastille ZFS options interactively? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
# Assume the user knows what hes/she doing and want to configure ZFS parameters interactively.
|
||||
@@ -368,7 +370,8 @@ configure_network() {
|
||||
# This is an initial attempt to make this function interactive,
|
||||
# however this may be enhanced in the future by advanced contributors in this topic.
|
||||
info "This will attempt to configure the loopback network interface [${bastille_network_loopback}]."
|
||||
read -p "$(warn "Would you like to configure the loopback network interface now? [y/N]: ")" _response
|
||||
warn "Would you like to configure the loopback network interface now? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
# shellcheck disable=SC2104
|
||||
@@ -400,7 +403,8 @@ configure_vnet() {
|
||||
# This is an initial attempt to make this function interactive,
|
||||
# however this may be enhanced in the future by advanced contributors in this topic.
|
||||
info "This will attempt to configure the VNET bridge interface [${bastille_ifbridge_name}]."
|
||||
read -p "$(warn "Would you like to configure the VNET bridge interface now? [y/N]: ")" _response
|
||||
warn "Would you like to configure the VNET bridge interface now? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
# shellcheck disable=SC2104
|
||||
@@ -454,7 +458,8 @@ configure_pf() {
|
||||
# This is an initial attempt to make this function interactive,
|
||||
# however this may be enhanced in the future by advanced contributors in this topic.
|
||||
info "This will attempt to configure the PF firewall parameters in [${bastille_pf_conf}]."
|
||||
read -p "$(warn "Would you like to configure the PF firewall parameters now? [y/N]: ")" _response
|
||||
warn "Would you like to configure the PF firewall parameters now? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
# shellcheck disable=SC2104
|
||||
@@ -518,7 +523,6 @@ configure_zfs() {
|
||||
|
||||
ZFS_DATASET_DETECT=
|
||||
BASTILLE_CUSTOM_CONFIG=
|
||||
BASTILLE_INITIAL_CONFIG=
|
||||
local _response=
|
||||
|
||||
if ! kldstat -qm zfs; then
|
||||
@@ -530,7 +534,8 @@ configure_zfs() {
|
||||
# host filesystem, or the default configuration file has been changed officially and set to "NO" by default.
|
||||
if echo "${bastille_zfs_enable}" | grep -qi "no"; then
|
||||
info "Looks like Bastille ZFS has been disabled in 'bastille.conf', ZFS activation helper disabled."
|
||||
read -p "$(warn "Would you like to enable the ZFS activation helper now? [y/N]: ")" _response
|
||||
warn "Would you like to enable the ZFS activation helper now? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
# Assume the user wants to configure the ZFS parameters.
|
||||
@@ -557,7 +562,8 @@ configure_zfs() {
|
||||
if [ "${bastille_prefix}" = "${bastille_prefix_default}" ] && [ -z "${BASTILLE_CUSTOM_CONFIG}" ]; then
|
||||
show_zfs_params
|
||||
info "Looks like bastille has been installed and hasn't been bootstrapped yet."
|
||||
read -p "$(warn "Would you like to activate ZFS now to get the features and benefits? [y/N]"): " _response
|
||||
warn "Would you like to activate ZFS now to get the features and benefits? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
if [ -n "${BASTILLE_ZFSPOOL}" ]; then
|
||||
@@ -576,7 +582,8 @@ configure_zfs() {
|
||||
info "Looks like you cancelled the ZFS activation."
|
||||
# Offer the user option to disable ZFS in the configuration file.
|
||||
# Maybe the user wants to use UFS or ZFS with legacy directories instead.
|
||||
read -p "$(warn "Would you like to explicitly disable ZFS in the configuration file? [y/N]: ")" _response
|
||||
warn "Would you like to explicitly disable ZFS in the configuration file? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
if config_backup; then
|
||||
@@ -611,7 +618,8 @@ configure_zfs() {
|
||||
info "Attempting to configure default ZFS options for you..."
|
||||
if zfs list | grep -qw "${bastille_prefix}"; then
|
||||
ZFS_DATASET_DETECT="1"
|
||||
read -p "$(warn "Would you like to auto-configure the detected ZFS parameters now? [y/N]: ")" _response
|
||||
warn "Would you like to auto-configure the detected ZFS parameters now? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
if config_backup; then
|
||||
@@ -637,7 +645,8 @@ configure_zfs() {
|
||||
# We do not want to cause existing data lost at all due end-user errors.
|
||||
warn "Looks like bastille prefix is not a ZFS dataset, thus ZFS storage options are not required."
|
||||
warn "Please refer to 'bastille.conf' and/or verify for alreay existing 'bastille_prefix' directory."
|
||||
read -p "$(warn "Would you like to explicitly disable ZFS in the configuration file so we don't ask again? [y/N]: ")" _response
|
||||
warn "Would you like to explicitly disable ZFS in the configuration file so we don't ask again? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
if config_backup; then
|
||||
@@ -690,13 +699,17 @@ configure_zfs_manually() {
|
||||
local _zfsmount_select=
|
||||
local _response=
|
||||
|
||||
read -p "$(info "Would you like to configure the ZFS parameters entirely by hand? [y/N]: ")" _response
|
||||
info "Would you like to configure the ZFS parameters entirely by hand? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
# We will assume the user knows what hes/she doing and want to configure ZFS parameters entirely by hand.
|
||||
read -p "$(warn "Please enter the desired ZFS pool for bastille: ")" _zfspool_select
|
||||
read -p "$(warn "Please enter the ZFS dataset for bastille: ")" _zfsprefix_select
|
||||
read -p "$(warn "Please enter the ZFS mountpoint for bastille: ")" _zfsmount_select
|
||||
warn "Please enter the desired ZFS pool for bastille: "
|
||||
read _zfspool_select
|
||||
warn "Please enter the ZFS dataset for bastille: "
|
||||
read _zfsprefix_select
|
||||
warn "Please enter the ZFS mountpoint for bastille: "
|
||||
read _zfsmount_select
|
||||
|
||||
# Set the parameters and show the user a preview.
|
||||
BASTILLE_PREFIXDEF="${_zfsmount_select}"
|
||||
@@ -706,7 +719,8 @@ configure_zfs_manually() {
|
||||
|
||||
# Ask again to make sure the user is confident with the entered parameters.
|
||||
warn "Are you sure the above bastille ZFS configuration is correct?"
|
||||
read -p "$(warn "Once bastille is activated it can't be easily undone, do you really want to activate ZFS now? [y/N]: ")" _response
|
||||
warn "Once bastille is activated it can't be easily undone, do you really want to activate ZFS now? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
BASTILLE_CONFIG_USER="1"
|
||||
@@ -740,7 +754,8 @@ configure_zfs_manually() {
|
||||
ZFSPOOL_COUNT=$(expr ${ZFSPOOL_COUNT} + 1)
|
||||
done
|
||||
|
||||
read -p "$(info "Please select the ZFS pool [NUM] for bastille: ")" _zfspool_choice
|
||||
info "Please select the ZFS pool [NUM] for bastille: "
|
||||
read _zfspool_choice
|
||||
if ! echo "${_zfspool_choice}" | grep -Eq "^[0-9]{1,3}$"; then
|
||||
error_exit "Invalid input number, aborting!"
|
||||
else
|
||||
@@ -751,7 +766,8 @@ configure_zfs_manually() {
|
||||
else
|
||||
info "Selected ZFS pool: [${_zfspool_select}]"
|
||||
# Ask again to make sure the user is confident in his election.
|
||||
read -p "$(warn "Are you sure '${_zfspool_select}' is the correct ZFS pool [y/N]: ")" _response
|
||||
warn "Are you sure '${_zfspool_select}' is the correct ZFS pool [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
# shellcheck disable=SC2104
|
||||
@@ -775,7 +791,8 @@ configure_zfs_manually() {
|
||||
ZFSDATA_NUM="${ZFSDATA_NUM} [${ZFSDATA_COUNT}]${_zprefix}"
|
||||
ZFSDATA_COUNT=$(expr ${ZFSDATA_COUNT} + 1)
|
||||
done
|
||||
read -p "$(info "Please select the ZFS dataset [NUM] for bastille: ")" _zfsprefix_choice
|
||||
info "Please select the ZFS dataset [NUM] for bastille: "
|
||||
read _zfsprefix_choice
|
||||
if ! echo "${_zfsprefix_choice}" | grep -Eq "^[0-9]{1,3}$"; then
|
||||
error_exit "Invalid input number, aborting!"
|
||||
else
|
||||
@@ -788,7 +805,8 @@ configure_zfs_manually() {
|
||||
_zfsprefix_trim=$(echo ${ZFSDATA_NUM} | grep -wo "\[${_zfsprefix_choice}\][^ ]*" | awk -F "${_zfspool_select}/" 'NR==1{print $2}')
|
||||
info "Selected ZFS prefix: [${_zfsprefix_select}]"
|
||||
# Ask again to make sure the user is confident in his election.
|
||||
read -p "$(warn "Are you sure '${_zfsprefix_select}' is the correct ZFS dataset [y/N]: ")" _response
|
||||
warn "Are you sure '${_zfsprefix_select}' is the correct ZFS dataset [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
# shellcheck disable=SC2104
|
||||
@@ -813,7 +831,8 @@ configure_zfs_manually() {
|
||||
MPREFIX_NUM="${MPREFIX_NUM} [${MPREFIX_COUNT}]${_zfsmount_choice}"
|
||||
MPREFIX_COUNT=$(expr ${MPREFIX_COUNT} + 1)
|
||||
done
|
||||
read -p "$(info "Please select the ZFS mountpoint [NUM] for bastille: ")" _zfsmount_choice
|
||||
info "Please select the ZFS mountpoint [NUM] for bastille: "
|
||||
read _zfsmount_choice
|
||||
if ! echo "${_zfsmount_choice}" | grep -Eq "^[0-9]{1,3}$"; then
|
||||
error_exit "Invalid input number, aborting!"
|
||||
else
|
||||
@@ -824,7 +843,8 @@ configure_zfs_manually() {
|
||||
else
|
||||
info "Selected bastille storage mountpoint: [${_zfsmount_select}]"
|
||||
# Ask again to make sure the user is confident in his election.
|
||||
read -p "$(warn "Are you sure '${_zfsmount_select}' is the correct bastille prefix [y/N]: ")" _response
|
||||
warn "Are you sure '${_zfsmount_select}' is the correct bastille prefix [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
# Set the parameters and show the user a preview.
|
||||
@@ -833,7 +853,8 @@ configure_zfs_manually() {
|
||||
BASTILLE_PREFIXZFS="${_zfsprefix_trim}"
|
||||
show_zfs_params
|
||||
warn "Are you sure the above bastille ZFS configuration is correct?"
|
||||
read -p "$(warn "Once bastille is activated it can't be easily undone, do you really want to activate ZFS now? [y/N]: ")" _response
|
||||
warn "Once bastille is activated it can't be easily undone, do you really want to activate ZFS now? [y/N]: "
|
||||
read _response
|
||||
case "${_response}" in
|
||||
[Yy]|[Yy][Ee][Ss])
|
||||
write_zfs_opts
|
||||
|
||||
Reference in New Issue
Block a user