currently scripting some mtree(8) handling in Bash to manage a repository of metadata of my programmatically accessible sources of music — friends' servers and μSD cards and player flash contents and personal computers
For now I dumped info of one place with the
below:
#!/usr/bin/env bash
set -euxo pipefail
repo="${1%%//*}"
content="${1#*//}"
while [ "${content: -1}" = "/" ]
do
content="${content%/}"
done
spis="$HOME/spis"
[ -d "$spis" ]
[ -d "$1" ]
[ -d "$repo/$content" ]
read -p "$content ?"
cspis="$spis/$content"
tmt="$cspis/mtree"
case "$REPLY" in
"" ) ;;
* )
if ! [ -f "$tmt" ]
then
echo "$1" >> "$spis/_nope"
fi
exit 0;;
esac
mkdir -p "$cspis"
temp=`mktemp`
nice gomtree validate -c -k size,md5digest,type,link -p "$1" -f "$temp"
install "$temp" "$tmt"
rm "$temp"
notka="$(mktemp -p "$cspis" -t place.`hostname -s`.XXXX )"
echo "$1" > "$notka"
Funny how it turned out that cksum ended up being awfully slow compared to md5 in go-mtree implementation