From 58ef5126f84a1abcad3cbfa0f8974fee388392e6 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Sat, 5 Jun 2021 16:01:21 +0200 Subject: [PATCH] .local/bin: Delete dataindex, encfsw. There are superseded by ambrevar/storage and ambrevar/encfs. --- .local/bin/dataindex | 78 -------------------------------------------- .local/bin/encfsw | 70 --------------------------------------- 2 files changed, 148 deletions(-) delete mode 100755 .local/bin/dataindex delete mode 100755 .local/bin/encfsw diff --git a/.local/bin/dataindex b/.local/bin/dataindex deleted file mode 100755 index eddf6c20..00000000 --- a/.local/bin/dataindex +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh - -usage () { - cat <&2 -Usage: ${0##*/} [OPTIONS] FOLDERS - -Output index of folder hierarchies to stdout. This is used as a small "backup" -purpose. In case of data loss, it is still possible to get the full file list -thanks to the indexes. - -Version control and encfs-encrypted folders are skipped. - -Options: - - -f: When outputting to a file, overwrite if it exists. - -w: Output each index to individual files in current folder. It uses the folder - name as basename. -EOF -} - -opt_noclobber=true -opt_file=false -while getopts ":fhw" opt; do - case $opt in - f) - opt_noclobber=false ;; - h) - usage - exit ;; - w) - opt_file=true ;; - \?) - usage - exit 1 ;; - esac -done - -shift $((OPTIND - 1)) - -if [ $# -eq 0 ]; then - usage - exit 1 -fi - -## 'realpath' is required in case argument is ending with '.' or '..'. -if ! command -v realpath >/dev/null 2>&1; then - echo >&2 "'realpath' not found" - exit 1 -fi - -for i ; do - [ ! -d "$i" ] && continue - [ -e "$i"/.encfs*.xml ] && continue - - ## We strip "./" from find's listing since we don't need it. We could avoid - ## printing it in the first place, but there are several shortcomings: - ## - Find over '.*' and '*', is bad practice since if will fail on - ## non-existing files or for files beginning with a dash. - ## - The 'printf' command in find is for GNU find only. - - ## 'LC_ALL=C sort' is required to make sure to output is consistent across - ## different systems. - - echo >&2 "$i" - ## The two following lines do the same for the same time cost. The former is shorter. - # find "$i" -type f | awk -v str="$i" '{l=length(str)+2; print substr($0, l)}' | LC_ALL=C sort > "$OUTPUT" - (cd -- "$i" && find . \( -path '*.git*' -o -path '*.svn*' -o -path '*.hg*' \) -prune -o -type f) | sed 's/^.\///' | LC_ALL=C sort | \ - if $opt_file; then - i="$(realpath -- "$i")" - base="${i##*/}" - output="$base.index" - [ -e "$output" ] && $opt_noclobber && output="$base-$(date +%F-%T).index" - echo "$output" - cat > "$output" - else - cat - fi -done diff --git a/.local/bin/encfsw b/.local/bin/encfsw deleted file mode 100755 index 43decf36..00000000 --- a/.local/bin/encfsw +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh - -if [ $# -ne 1 ] && [ $# -ne 2 ]; then - echo - cat</dev/null 2>&1; then - echo "'$i' not found in PATH. Exiting." >&2 - exit 1 - fi - done -} - -## REVIEW: Only set extpass if no PTY is connected? -if [ -z "$SUDO_ASKPASS" ] && command -v emacs-askpass >/dev/null 2>&1; then - SUDO_ASKPASS=emacs-askpass -fi - -mount() { - check realpath encfs - SOURCE="$(realpath "$1")" - MOUNTPOINT="${SOURCE}_decrypted" - mkdir -p "$MOUNTPOINT" - if [ -z "$PASS" ]; then - encfs --extpass="$SUDO_ASKPASS" "$SOURCE" "$MOUNTPOINT" || rmdir "$MOUNTPOINT" - else - echo "$PASS" | encfs --stdinpass "$SOURCE" "$MOUNTPOINT" || rmdir "$MOUNTPOINT" - fi -} - -unmount() { - check findmnt fusermount dataindex - - while IFS= read -r i; do - ## Generate index on exit. - folder=$(basename $(dirname "$i")) - mkdir -p "$PERSONAL"/index/"$folder" - dataindex "$i" | gpg --encrypt --recipient mail@ambrevar.xyz \ - --output - > "$PERSONAL"/index/"$folder"/"$(basename "$i")".index.gpg - unset folder - fusermount -u "$i" - rmdir "$i" - done <