Add cleanup function to destroy and allow clean restart
This commit is contained in:
parent
4dc3e37dc4
commit
9e54386b01
1 changed files with 37 additions and 0 deletions
|
@ -267,6 +267,38 @@ function install_expert() {
|
||||||
expert_step
|
expert_step
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function install_cleanup() {
|
||||||
|
if [[ "$DEBUG" ]]; then
|
||||||
|
local cmd="echo"
|
||||||
|
else
|
||||||
|
local cmd=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
for subvol in "${!SUBVOLS_DEFAULT[@]}"
|
||||||
|
do
|
||||||
|
${cmd} umount /target/"${SUBVOLS_DEFAULT[$subvol]}"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$SWAP" ]]; then
|
||||||
|
${cmd} umount /target/swap
|
||||||
|
fi
|
||||||
|
|
||||||
|
${cmd} umount /target/boot/efi
|
||||||
|
${cmd} umount /target/boot
|
||||||
|
${cmd} umount /target
|
||||||
|
|
||||||
|
if [[ "$ENCRYPTION" ]]; then
|
||||||
|
${cmd} cryptsetup luksClose luksvol
|
||||||
|
fi
|
||||||
|
|
||||||
|
${cmd} dd if=/dev/zero of="${RootPart}" bs=1024 count=10
|
||||||
|
${cmd} dd if=/dev/zero of="${EFIPart}" bs=1024 count=10
|
||||||
|
if [[ "$BootPart" != "@boot" ]]; then
|
||||||
|
${cmd} dd if=/dev/zero of="${BootPart}" bs=1024 count=10
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
declare -a POSITIONAL_ARGS=()
|
declare -a POSITIONAL_ARGS=()
|
||||||
declare INSTALL_MODE="normal"
|
declare INSTALL_MODE="normal"
|
||||||
|
|
||||||
|
@ -291,6 +323,10 @@ while [[ $# -gt 0 ]]; do
|
||||||
INSTALL_MODE=expert
|
INSTALL_MODE=expert
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--clean)
|
||||||
|
INSTALL_MODE=clean
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
POSITIONAL_ARGS+=("$1") # save positional arg
|
POSITIONAL_ARGS+=("$1") # save positional arg
|
||||||
shift
|
shift
|
||||||
|
@ -317,6 +353,7 @@ else
|
||||||
case "$INSTALL_MODE" in
|
case "$INSTALL_MODE" in
|
||||||
normal) install_normal;;
|
normal) install_normal;;
|
||||||
expert) install_expert;;
|
expert) install_expert;;
|
||||||
|
clean) install_cleanup;;
|
||||||
*)
|
*)
|
||||||
echo "Error, unknown installation mode detected."
|
echo "Error, unknown installation mode detected."
|
||||||
exit 3
|
exit 3
|
||||||
|
|
Loading…
Reference in a new issue