Fix unmounting folders.

This commit is contained in:
Tom Alexander 2022-02-26 18:54:56 -05:00
parent 3b131ed462
commit 273f5cd2ad
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -7,13 +7,18 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
############## Setup ######################### ############## Setup #########################
function cleanup { function cleanup {
sync
for f in "${gpgagents[@]}"; do
>&2 echo "Killing gpg-agent $f"
GNUPGHOME="$f" gpgconf --kill gpg-agent
done
for f in "${jails[@]}"; do for f in "${jails[@]}"; do
>&2 echo "Stopping jail $f" >&2 echo "Stopping jail $f"
jail -r "$f" jail -r "$f"
done done
for (( idx=${#mountedfolders[@]}-1 ; idx>=0 ; idx-- )) ; do for (( idx=${#mountedfolders[@]}-1 ; idx>=0 ; idx-- )) ; do
>&2 echo "Unmounting folder ${mountedfolders[idx]}" >&2 echo "Unmounting folder ${mountedfolders[idx]}"
umount "${mountedfolders[idx]}" umount -f "${mountedfolders[idx]}"
done done
for f in "${memorydevices[@]}"; do for f in "${memorydevices[@]}"; do
>&2 echo "Removing memory device $f" >&2 echo "Removing memory device $f"
@ -28,6 +33,7 @@ folders=()
jails=() jails=()
memorydevices=() memorydevices=()
mountedfolders=() mountedfolders=()
gpgagents=()
for sig in EXIT INT QUIT HUP TERM; do for sig in EXIT INT QUIT HUP TERM; do
trap "set +e; cleanup" "$sig" trap "set +e; cleanup" "$sig"
done done
@ -157,8 +163,11 @@ function download_alpine {
sha256 -c "$ALPINE_SHA256" "${download_directory}/${ALPINE_TARBALL}" sha256 -c "$ALPINE_SHA256" "${download_directory}/${ALPINE_TARBALL}"
local keyring="$work_directory/keyring" local keyring="$work_directory/keyring"
gpg --no-default-keyring --keyring "$keyring" --trust-model always --import <<<"$ALPINE_KEY" local gpghome="$work_directory/gpghome"
gpg --no-default-keyring --keyring "$keyring" --trust-model always --verify <(cat <<<"$ALPINE_SIGNATURE") "${download_directory}/${ALPINE_TARBALL}" (umask 077 && mkdir "$gpghome")
GNUPGHOME="$gpghome" gpg --no-default-keyring --keyring "$keyring" --trust-model always --import <<<"$ALPINE_KEY"
gpgagents+=("$gpghome")
GNUPGHOME="$gpghome" gpg --no-default-keyring --keyring "$keyring" --trust-model always --verify <(cat <<<"$ALPINE_SIGNATURE") "${download_directory}/${ALPINE_TARBALL}"
} }
function make_chroot { function make_chroot {