Kill gpg-agent in the normal script process.

This commit is contained in:
Tom Alexander 2022-02-27 20:00:42 -05:00
parent 8e2eac5865
commit c2b410a908
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -8,25 +8,22 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function cleanup {
sync
for f in "${gpgagents[@]}"; do
>&2 echo "Killing gpg-agent $f"
GNUPGHOME="$f" gpgconf --kill gpg-agent
done
kill_gpg_agent
for f in "${jails[@]}"; do
>&2 echo "Stopping jail $f"
log "Stopping jail $f"
jail -r "$f"
done
for (( idx=${#mountedfolders[@]}-1 ; idx>=0 ; idx-- )) ; do
>&2 echo "Unmounting folder ${mountedfolders[idx]}"
log "Unmounting folder ${mountedfolders[idx]}"
umount "${mountedfolders[idx]}"
done
for f in "${memorydevices[@]}"; do
>&2 echo "Removing memory device $f"
log "Removing memory device $f"
mdconfig -d -u "$f"
done
for f in "${folders[@]}"; do
>&2 echo "Deleting $f"
# rm -rf "$f"
log "Deleting $f"
rm -rf "$f"
done
}
folders=()
@ -222,6 +219,18 @@ function make_image {
mountedfolders+=("$boot_directory")
}
function kill_gpg_agent {
for f in "${gpgagents[@]}"; do
log "Killing gpg-agent $f"
GNUPGHOME="$f" gpgconf --kill gpg-agent
done
unset gpgagents
}
function unmount_image {
echo "foo"
}
function main {
precheck
@ -243,6 +252,8 @@ function main {
log "Building chroot in $chroot"
make_chroot
kill_gpg_agent
log "Copying final image to $DIR"
cp "$image_file" "$DIR"
}