mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-29 08:50:34 +01:00
Merge pull request #782 from BastilleBSD/setup-config-file
Improve bastille.conf handling with user prompt for creation
This commit is contained in:
@@ -32,10 +32,20 @@ PATH=${PATH}:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
|
||||
|
||||
. /usr/local/share/bastille/common.sh
|
||||
|
||||
## check for config existance
|
||||
## check for config existence
|
||||
bastille_conf_check() {
|
||||
if [ ! -r "/usr/local/etc/bastille/bastille.conf" ]; then
|
||||
error_exit "Missing Configuration"
|
||||
warn "Configuration file not found. Do yu want to create it with default values? [y/N]"
|
||||
read answer
|
||||
case "${answer}" in
|
||||
[Nn][Oo]|[Nn]|"")
|
||||
error_exit "No configuration file has been generated. Exiting."
|
||||
;;
|
||||
[Yy][Ee][Ss]|[Yy])
|
||||
cp /usr/local/etc/bastille/bastille.conf.sample /usr/local/etc/bastille/bastille.conf
|
||||
info "Configuration file has been generated. Continuing with default values"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,6 @@
|
||||
|
||||
bastille_config="/usr/local/etc/bastille/bastille.conf"
|
||||
. /usr/local/share/bastille/common.sh
|
||||
|
||||
# TODO: This not going to take effect since Bastille checks the file
|
||||
# before running this subcommand. We will need to check an strategy.
|
||||
if [ ! -f "${bastille_config}" ]; then
|
||||
cp /usr/local/etc/bastille/bastille.conf.sample ${bastille_config}
|
||||
fi
|
||||
|
||||
# shellcheck source=/usr/local/etc/bastille/bastille.conf
|
||||
. ${bastille_config}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user