This commit is contained in:
Fabian Montero 2025-02-07 19:11:17 -06:00
parent ce932e2a06
commit 1114feb79d
Signed by: fabian
GPG key ID: 1FFAC35E1798174F

View file

@ -3,35 +3,43 @@
set -e set -e
set -o pipefail set -o pipefail
[ -n "$1" ] || { echo "error: Provide a beacon address" >&2; exit 1; }
BEACON="$1"
[ -n "$FSOCIETY_TELEGRAM_BACKUP_N" ] || { echo "error: N env var not set." >&2; exit 1; }
[ -n "$FSOCIETY_TELEGRAM_BACKUP_LOCATION" ] || { echo "error: N env var not set." >&2; exit 1; }
ALPHABET="0 1 2"
BEACONPORT="60666"
WORKDIR="/run/user/$UID/ftb"
ZIPPED_KEYS="$FSOCIETY_TELEGRAM_BACKUP_LOCATION/fsociety-archive-secret-slot$FSOCIETY_TELEGRAM_BACKUP_N.zip.gpg"
TOMB="$FSOCIETY_TELEGRAM_BACKUP_LOCATION/fsociety-archive-2024-01-05.img"
cleanup() {
sudo umount ./backup
sudo cryptsetup close /dev/mapper/fsociety_backup
sudo sudo chattr +i "$TOMB" "$ZIPPED_KEYS"
rm -rfd "$WORKDIR"
}
trap cleanup EXIT
check_dependency() { check_dependency() {
command -v $1 > /dev/null || { echo "error: $1 not found" >&2; exit 1; } command -v $1 > /dev/null || { echo "error: $1 not found" >&2; exit 1; }
} }
check_dependencies() { check_dependencies() {
for dep in "$@"; do for dep in "$@"; do
check_dependency "$dep" check_dependency "$dep"
done done
} }
check_dependencies "firefox" "ncat" "gpg" "cryptsetup" "unzip" "shred" check_dependencies "firefox" "ncat" "gpg" "cryptsetup" "unzip" "shred"
[ -n "$FSOCIETY_TELEGRAM_BACKUP_N" ] || { echo "error: N env var not set." >&2; exit 1; }
[ -n "$FSOCIETY_TELEGRAM_BACKUP_LOCATION" ] || { echo "error: N env var not set." >&2; exit 1; }
[ -n "$1" ] || { echo "error: Provide a beacon address" >&2; exit 1; }
BEACON="$1"
ALPHABET="0 1 2"
BEACONPORT="60666"
WORKDIR="/run/user/$UID/ftb"
[ ! -e "$WORKDIR" ] || { echo "error: Delete $WORKDIR." >&2; exit 1; } [ ! -e "$WORKDIR" ] || { echo "error: Delete $WORKDIR." >&2; exit 1; }
mkdir -p "$WORKDIR" mkdir -p "$WORKDIR"
cd "$WORKDIR" cd "$WORKDIR"
ZIPPED_KEYS="$FSOCIETY_TELEGRAM_BACKUP_LOCATION/fsociety-archive-secret-slot$FSOCIETY_TELEGRAM_BACKUP_N.zip.gpg"
TOMB="$FSOCIETY_TELEGRAM_BACKUP_LOCATION/fsociety-archive-2024-01-05.img"
sudo sudo chattr -i "$TOMB" "$ZIPPED_KEYS" sudo sudo chattr -i "$TOMB" "$ZIPPED_KEYS"
gpg -d "$ZIPPED_KEYS" > keys.zip gpg -d "$ZIPPED_KEYS" > keys.zip
@ -50,10 +58,6 @@ mkdir -p "$FFPROFILE"
firefox -profile "$FFPROFILE" --no-remote ./backup/messages.html firefox -profile "$FFPROFILE" --no-remote ./backup/messages.html
find "$FFPROFILE" -type f -exec shred {} \; find "$FFPROFILE" -type f -exec shred {} \;
sudo umount ./backup cleanup()
sudo cryptsetup close /dev/mapper/fsociety_backup
sudo sudo chattr +i "$TOMB" "$ZIPPED_KEYS"
rm -rfd "$WORKDIR"
echo "I go to my fathers... in whose mighty company... I shall not now feel ashamed." echo "I go to my fathers... in whose mighty company... I shall not now feel ashamed."