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 {
|
function cleanup {
|
||||||
sync
|
sync
|
||||||
kill_gpg_agent
|
kill_gpg_agent
|
||||||
for f in "${jails[@]}"; do
|
stop_jails
|
||||||
log "Stopping jail $f"
|
unmount_folders
|
||||||
jail -r "$f"
|
remove_memory_devices
|
||||||
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
|
|
||||||
for f in "${folders[@]}"; do
|
for f in "${folders[@]}"; do
|
||||||
log "Deleting $f"
|
log "Deleting $f"
|
||||||
rm -rf "$f"
|
rm -rf "$f"
|
||||||
@ -227,8 +218,28 @@ function kill_gpg_agent {
|
|||||||
unset gpgagents
|
unset gpgagents
|
||||||
}
|
}
|
||||||
|
|
||||||
function unmount_image {
|
function stop_jails {
|
||||||
echo "foo"
|
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 {
|
function main {
|
||||||
@ -253,6 +264,9 @@ function main {
|
|||||||
make_chroot
|
make_chroot
|
||||||
|
|
||||||
kill_gpg_agent
|
kill_gpg_agent
|
||||||
|
stop_jails
|
||||||
|
unmount_folders
|
||||||
|
remove_memory_devices
|
||||||
|
|
||||||
log "Copying final image to $DIR"
|
log "Copying final image to $DIR"
|
||||||
cp "$image_file" "$DIR"
|
cp "$image_file" "$DIR"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user