Browse Source

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

master
Jérémy Lecour 2 weeks ago
parent
commit
bf56c16ed2
2 changed files with 25 additions and 0 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +24
    -0
      lib/bkctld-remove

+ 1
- 0
CHANGELOG.md View File

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



+ 24
- 0
lib/bkctld-remove View File

@@ -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…
Cancel
Save