Improve cleanup_and_exit
This commit is contained in:
parent
fd8eb4f1ee
commit
f2fbe8f1f5
1 changed files with 8 additions and 6 deletions
14
arkdep
14
arkdep
|
@ -39,20 +39,22 @@ cleanup_and_quit () {
|
||||||
# If any paramters are passed we will assume it to be an error message
|
# If any paramters are passed we will assume it to be an error message
|
||||||
[[ -n $1 ]] && printf "\e[1;31m<#>\e[0m $*\e[0m\n" >&2
|
[[ -n $1 ]] && printf "\e[1;31m<#>\e[0m $*\e[0m\n" >&2
|
||||||
|
|
||||||
|
# Ensure we do not try to remove our current deployment
|
||||||
|
if grep "$(readlink -m $arkdep_dir/deployments/$deployment)" /proc/cmdline > /dev/null; then
|
||||||
|
printf "\e[1;33m<!>\e[0m\e[1m Cleanup target is current active deployment, skipping\e[0m\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove the subvolume we were working on
|
# Remove the subvolume we were working on
|
||||||
# TODO: Make this a generic function and share with the removal of old images?
|
# TODO: Make this a generic function and share with the removal of old images?
|
||||||
if [[ -n ${data[0]} ]]; then
|
if [[ -n ${data[0]} ]]; then
|
||||||
btrfs property set -f -ts $arkdep_dir/deployments/${data[0]}/rootfs ro false
|
btrfs property set -f -ts $(readlink -m $arkdep_dir/deployments/${data[0]}/rootfs) ro false
|
||||||
rm -rf $arkdep_dir/deployments/${data[0]}
|
rm -rf $arkdep_dir/deployments/${data[0]}
|
||||||
rm -rf /boot/arkdep/${data[0]}
|
rm -rf /boot/arkdep/${data[0]}
|
||||||
rm /boot/loader/entries/${data[0]}.conf
|
rm /boot/loader/entries/${data[0]}.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Quit program if argument provided to function
|
exit 1
|
||||||
[[ -n $1 ]] && exit 1
|
|
||||||
|
|
||||||
# Otherwise just quit, there is no error
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue