[arkdep] Check if target is active deployment on remove before asking for confirmation

This commit is contained in:
Dennis ten Hoove 2024-07-26 01:50:30 +02:00
parent 50f39d89ee
commit 960034ba5a
No known key found for this signature in database
GPG key ID: 2BA91DC2563B83D1

16
arkdep
View file

@ -465,6 +465,14 @@ remove_deployment () {
declare target=${hits[0]} declare target=${hits[0]}
printf "Removing $target\n"
# Ensure deployment is not currently active
if grep -q "$arkdep_dir/deployments/$target/rootfs" /proc/cmdline; then
printf '\e[1;33m<!>\e[0m\e[1m Target is current active deployment\e[0m\n'
continue
fi
if [[ $interactive_mode -eq 1 ]] && [[ $cleanup_no_confirm -ne 1 ]] && [[ $ARKDEP_CONFIRM -ne 1 ]]; then if [[ $interactive_mode -eq 1 ]] && [[ $cleanup_no_confirm -ne 1 ]] && [[ $ARKDEP_CONFIRM -ne 1 ]]; then
printf "$target will be removed.\n\n" printf "$target will be removed.\n\n"
read -p 'Proceed with removal? [Y/n] ' remove_confirm read -p 'Proceed with removal? [Y/n] ' remove_confirm
@ -474,14 +482,6 @@ remove_deployment () {
fi fi
fi fi
printf "Removing $target\n"
# Ensure deployment is not currently active
if grep -q "$arkdep_dir/deployments/$target/rootfs" /proc/cmdline; then
printf '\e[1;33m<!>\e[0m\e[1m Target is current active deployment\e[0m\n'
continue
fi
# Remove bootloader entry # Remove bootloader entry
rm -rfv $arkdep_boot/loader/entries/$target.conf rm -rfv $arkdep_boot/loader/entries/$target.conf
rm -rfv $arkdep_boot/arkdep/$target rm -rfv $arkdep_boot/arkdep/$target