.local/bin: Delete dataindex, encfsw.

There are superseded by ambrevar/storage and ambrevar/encfs.
master
Pierre Neidhardt 2021-06-05 16:01:21 +02:00
parent 6641bc3fd5
commit 58ef5126f8
2 changed files with 0 additions and 148 deletions

View File

@ -1,78 +0,0 @@
#!/bin/sh
usage () {
cat <<EOF>&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

View File

@ -1,70 +0,0 @@
#!/bin/sh
if [ $# -ne 1 ] && [ $# -ne 2 ]; then
echo
cat<<EOF
Usage: $0 FOLDERS...
$0 -u
Mount encfs-encrypted FOLDERS.
With -u, unmount all encfs-mounted partitions.
EOF
exit
fi
check() {
for i ; do
if ! command -v $i >/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 <<EOF
$(findmnt --noheadings --output=target encfs)
EOF
}
if [ "$1" = "-u" ]; then
unmount
exit 0
fi
if [ $# -gt 1 ]; then
echo -n "EncFS Password: "
read PASS
fi
for i; do
mount "$i"
done