Finish incorporating cleanup in the normal shutdown process.
This commit is contained in:
parent
c2b410a908
commit
8234e06861
@ -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…
Reference in New Issue
Block a user