forked from evolix/evobackup
bkctld-remove: confirmation before removal of jails if not in force mode
This commit is contained in:
parent
2ccd8c1b8d
commit
bf56c16ed2
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Added
|
||||
|
||||
* bkctld: add a [-f|--force] option to remove confirmation on some commands
|
||||
* bkctld-remove: confirmation before removal of jails if not in force mode
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#
|
||||
# Description: Remove jail and all dated copies (incs)
|
||||
# Usage: remove <jailname>|all
|
||||
# Return codes:
|
||||
# * 101 : jail removal aborted
|
||||
#
|
||||
|
||||
# shellcheck source=./includes
|
||||
|
@ -16,6 +18,28 @@ incs_path=$(incs_path "${jail_name}")
|
|||
|
||||
test -d "${jail_path}" || error "${jail_name}: jail not found" 2
|
||||
|
||||
if [ "${FORCE}" != "1" ]; then
|
||||
answer=""
|
||||
while :; do
|
||||
printf "> Are you sure you want to delete jail \`%s'? [Y,n,?] " "${jail_name}"
|
||||
read -r answer
|
||||
case $answer in
|
||||
[Yy]|"" )
|
||||
break
|
||||
;;
|
||||
[Nn] )
|
||||
tty -s && echo "Abort." >&2
|
||||
exit 101
|
||||
;;
|
||||
* )
|
||||
printf "y - yes, execute actions and exit\n"
|
||||
printf "n - no, don't execute actions and exit\n"
|
||||
printf "? - print this help\n"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
"${LIBDIR}/bkctld-is-on" "${jail_name}" && "${LIBDIR}/bkctld-stop" "${jail_name}"
|
||||
|
||||
rm -f "${CONFDIR}/${jail_name}"
|
||||
|
|
Loading…
Reference in a new issue