From 671efcd4d8b6421b7c5eb5697d92ea6848257e33 Mon Sep 17 00:00:00 2001 From: will king Date: Mon, 22 Apr 2024 20:44:05 -0700 Subject: [PATCH 1/3] added some files that are present on home-pc --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 72e6cd9..418ce6d 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ tikzit/ update-zoom *.llamafile llms/ +nu-0.87.1-x86_64-linux-gnu-full/ +nu-0.87.1-x86_64-linux-gnu-full.tar.gz From 69d154ed0b27e77aa6ed7a2d9b31ed852752fa2f Mon Sep 17 00:00:00 2001 From: will king Date: Mon, 9 Sep 2024 14:32:27 -0700 Subject: [PATCH 2/3] added script to simplify use of age with temp files --- tempage.sh | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100755 tempage.sh diff --git a/tempage.sh b/tempage.sh new file mode 100755 index 0000000..a65f8ea --- /dev/null +++ b/tempage.sh @@ -0,0 +1,136 @@ +#!/bin/sh +# Tempage is a script to simplify the use of AGE with tempfiles. +# The purpose is to be able to work with files that you don't want to have touch a disk in unencrypted format +# +# The basic workflow is: +# - create a temp dir +# - extract an tar.gz.age file to that dir OR mark that you are working with a new dir. +# - Work on the files, add files, etc. +# - Save the files and close any editors. +# - Setup recipients +# - create tar.gz.age file in original directory +# - remove temp file + + + + +#### STARTUP +# Setup temp dir and configure cleanup and trap to exit securely + +TMP_DIR="$(mktemp -d)" + +cleanup_tmp() { + rm -rf "$TMP_DIR" +} + +cleanup_on_trap() { + echo "Removing all Temp Files" + cleanup_tmp + echo "Done. Temp Files removed." + exit 1 +} + +trap cleanup_on_trap INT TERM + +help() { +echo << eof + HELP TEXT +eof +} + +### Interpret command line parameters +ARCHIVE_FILEPATH="" +OUTPUT_FILEPATH="" +NEW_ARCHIVE="" +PRIVATE_KEYS="~/.age/private_keys" + +while [ "$#" -gt 0 ]; do + case $1 in + -h|--help) + help + cleanup_tmp + exit 0 + ;; + -f|--file) # Handle -f or --file argument with a separate value + ARCHIVE_FILEPATH="$2" + shift + ;; + --file=*) # Handle --file=[path/to/file] argument + ARCHIVE_FILEPATH="${1#*=}" + ;; + -n|--new) # Handle -n or --new argument + NEW_ARCHIVE=true + ;; + -o|--output) + OUTPUT_FILEPATH="$2" + shift + ;; + --output=*) # Handle --file=[path/to/file] argument + OUTPUT_FILEPATH="${1#*=}" + ;; + -i|--identies) # Handle -f or --file argument with a separate value + PRIVATE_KEYS="$2" + shift + ;; + --identities=*) # Handle --file=[path/to/file] argument + PRIVATE_KEYS="${1#*=}" + ;; + *) + echo "Unknown parameter passed: $1" + cleanup_on_trap + exit 1 + ;; + esac + shift +done + +# Get names for config and temp files +RECIPIENTS="$TMP_DIR/recipients.txt" + + +if [ -n "$NEW_ARCHIVE" ] ; then #if creating a new archive, create the config file. + echo "#Creators Key\nage18jmnun5mrmjzf5gq60w8zjhl80nwhpw0d3qdgw6gjehf4u5agvvsu5kd0j\n" >> "$RECIPIENTS" + echo "Please edit the recipeints file found at: $RECIPIENTS. It currently only has the program creator's key. UNTIL YOU FIX IT, THIS WILL NOT SECURLY ENCRYPT ANY THING. Don't forget to include your own public key or you will not be able to read it either." +elif [ -s $ARCHIVE_FILEPATH ] && [ -s "$PRIVATE_KEYS" ]; then + # decrypt and extract into temp dir + age -d -i "$PRIVATE_KEYS" -o - "$ARCHIVE_FILEPATH" | tar -xzf - -C "$TMP_DIR" +else + echo "No valid operation specified. Try $0 --help" + exit 2 +fi + +# Continue working with file + +while true; do + echo "Enter command: \n\thelp|h, \n\tptd (print temp directory), \n\topen|o (open temp directory in GUI), \n\tencrypt|save|s (encrypt files), \n\texit|e|q (exit without saving/encrypting files)]:" + read CMD + + case $CMD in + h|help) + help + ;; + ptd|p) + echo "current temp directory is $TMP_DIR" + ;; + open|o) + echo "Opening temp dir" + xdg-open $TMP_DIR + ;; + s|save|encrypt) + echo "Saving and encrypting files as they exist in temp directory" + if [ -z "$OUTPUT_FILEPATH" ]; then + echo "Please provide a path to save to:" + read OUTPUT_FILEPATH + fi + tar -czf - -C "$TMP_DIR" . | age -R "$RECIPIENTS" -o "$OUTPUT_FILEPATH" - + ;; + e|q|exit) + cleanup_tmp + exit 0 + ;; + *) + echo "Invalid command." + ;; + esac +done + From 38341a1a9e5fb88b606f1277b59cd682fc71c738 Mon Sep 17 00:00:00 2001 From: will king Date: Sun, 15 Sep 2024 15:28:36 -0700 Subject: [PATCH 3/3] wrote help string for tempage.sh --- tempage.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tempage.sh b/tempage.sh index a65f8ea..9e8adc3 100755 --- a/tempage.sh +++ b/tempage.sh @@ -33,8 +33,18 @@ cleanup_on_trap() { trap cleanup_on_trap INT TERM help() { -echo << eof - HELP TEXT +cat << eof +Help for $0 + +Options +-h|--help #This help doc +-f|--file [path/to/file.tar.gz.age] # provides the tar'd, compressed, and encrypted file of interest. +--file=[path/to/file.tar.gz.age] # Alternate version of -h [file] +-n|--new # Create a new archive for encryption. +-o|--output [path/to/output/file.tar.gz.age] # Where to write the archive when you save it. +--output=[path/to/output/file.tar.gz.age] # Alternate version of -o [file] +-i|--identies [path/to/age/key] # Which identity to use to decrypt the file. +--identities=[path/to/age/key] # alternate form of -i [file] eof }