Finish incorporating cleanup in the normal shutdown process.

master
Tom Alexander 2 years ago
parent c2b410a908
commit 8234e06861
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -9,18 +9,9 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function cleanup {
sync
kill_gpg_agent
for f in "${jails[@]}"; do
log "Stopping jail $f"
jail -r "$f"
done
for (( idx=${#mountedfolders[@]}-1 ; idx>=0 ; idx-- )) ; do
log "Unmounting folder ${mountedfolders[idx]}"
umount "${mountedfolders[idx]}"
done
for f in "${memorydevices[@]}"; do
log "Removing memory device $f"
mdconfig -d -u "$f"
done
stop_jails
unmount_folders
remove_memory_devices
for f in "${folders[@]}"; do
log "Deleting $f"
rm -rf "$f"
@ -227,8 +218,28 @@ function kill_gpg_agent {
unset gpgagents
}
function unmount_image {
echo "foo"
function stop_jails {
for f in "${jails[@]}"; do
log "Stopping jail $f"
jail -r "$f"
done
unset jails
}
function unmount_folders {
for (( idx=${#mountedfolders[@]}-1 ; idx>=0 ; idx-- )) ; do
log "Unmounting folder ${mountedfolders[idx]}"
umount "${mountedfolders[idx]}"
done
unset mountedfolders
}
function remove_memory_devices {
for f in "${memorydevices[@]}"; do
log "Removing memory device $f"
mdconfig -d -u "$f"
done
unset memorydevices
}
function main {
@ -253,6 +264,9 @@ function main {
make_chroot
kill_gpg_agent
stop_jails
unmount_folders
remove_memory_devices
log "Copying final image to $DIR"
cp "$image_file" "$DIR"

Loading…
Cancel
Save