bkctld-remove: confirmation before removal of jails if not in force mode

Cette révision appartient à :
Jérémy Lecour 2020-10-11 15:19:00 +02:00
Parent 2ccd8c1b8d
révision bf56c16ed2
2 fichiers modifiés avec 25 ajouts et 0 suppressions

Voir le fichier

@ -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

Voir le fichier

@ -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}"