summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2018-04-07 10:18:37 -0600
committerAaron Ball <nullspoon@oper.io>2018-04-07 10:18:37 -0600
commit6f342ac6d0af9daacf76be5e096a04b5b646320f (patch)
treee774b47ecdbb066b6b02c791459848eb34295faf
parent4ece4f35be91fa5f7dac644e9038070239302ba9 (diff)
downloadgpgsecure-6f342ac6d0af9daacf76be5e096a04b5b646320f.tar.gz
gpgsecure-6f342ac6d0af9daacf76be5e096a04b5b646320f.tar.xz
Handle more signals
Previously, we just handled sigint. Now we also trap sigterm, sigkill, sigquit, and sighup. These will [hopefully] prevent data loss in the event we receive unexpected signals. Also removed a couple of messages that printed to stdout.
-rwxr-xr-xgpgsecure.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/gpgsecure.sh b/gpgsecure.sh
index b9796c2..bcb974d 100755
--- a/gpgsecure.sh
+++ b/gpgsecure.sh
@@ -19,12 +19,12 @@
export KEY=${KEY:-} # GPG key to encrypt the container with
export DIR # Directory path to present the gpg archive to
export TMP # Temp directory in memory to decrypt to
-trap shutdown SIGINT
+
+trap shutdown SIGINT SIGTERM SIGKILL SIGQUIT SIGHUP
+
shutdown() {
- printf '\nRe-encrypting for shutdown\n'
tar -C "${TMP}" -c . | gpg -e --recipient "${KEY}" > "${DIR}.tar.gpg"
- printf 'Shredding\n'
# Shred all files in memory
find "${TMP}" -type f -exec shred -n 100 -f -u "{}" \;
# Delete the link

Generated by cgit