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 { function cleanup {
sync sync
for f in "${gpgagents[@]}"; do kill_gpg_agent
>&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" log "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]}" log "Unmounting folder ${mountedfolders[idx]}"
umount "${mountedfolders[idx]}" umount "${mountedfolders[idx]}"
done done
for f in "${memorydevices[@]}"; do for f in "${memorydevices[@]}"; do
>&2 echo "Removing memory device $f" log "Removing memory device $f"
mdconfig -d -u "$f" mdconfig -d -u "$f"
done done
for f in "${folders[@]}"; do for f in "${folders[@]}"; do
>&2 echo "Deleting $f" log "Deleting $f"
# rm -rf "$f" rm -rf "$f"
done done
} }
folders=() folders=()
@ -222,6 +219,18 @@ function make_image {
mountedfolders+=("$boot_directory") 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 { function main {
precheck precheck
@ -243,6 +252,8 @@ function main {
log "Building chroot in $chroot" log "Building chroot in $chroot"
make_chroot make_chroot
kill_gpg_agent
log "Copying final image to $DIR" log "Copying final image to $DIR"
cp "$image_file" "$DIR" cp "$image_file" "$DIR"
} }