2020-05-24 14:52:09 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
2021-08-31 19:01:47 +02:00
|
|
|
cleanup() {
|
2020-05-24 22:02:34 +02:00
|
|
|
cd "$LOCAL_TMP"
|
|
|
|
fusermount -u gocryptfs.mnt
|
2020-05-24 14:52:09 +02:00
|
|
|
rm -Rf "$SSHFS_TMP"
|
2020-05-24 22:02:34 +02:00
|
|
|
fusermount -u sshfs.mnt
|
2020-05-24 14:52:09 +02:00
|
|
|
cd /
|
|
|
|
rm -Rf "$LOCAL_TMP"
|
|
|
|
}
|
|
|
|
|
2021-08-31 19:01:47 +02:00
|
|
|
prepare_mounts() {
|
2020-05-24 14:52:09 +02:00
|
|
|
LOCAL_TMP=$(mktemp -d -t "$MYNAME.XXX")
|
2021-08-31 19:01:47 +02:00
|
|
|
cd "$LOCAL_TMP"
|
2020-05-24 14:52:09 +02:00
|
|
|
echo "working directory: $PWD"
|
|
|
|
mkdir sshfs.mnt gocryptfs.mnt
|
2021-08-31 19:01:47 +02:00
|
|
|
sshfs "$HOST:/tmp" sshfs.mnt
|
2020-05-24 14:52:09 +02:00
|
|
|
echo "sshfs mounted: $HOST:/tmp -> sshfs.mnt"
|
|
|
|
trap cleanup EXIT
|
|
|
|
SSHFS_TMP=$(mktemp -d "sshfs.mnt/$MYNAME.XXX")
|
2021-08-31 19:01:47 +02:00
|
|
|
mkdir "$SSHFS_TMP/gocryptfs.crypt"
|
|
|
|
gocryptfs -q -init -extpass "echo test" -scryptn=10 "$SSHFS_TMP/gocryptfs.crypt"
|
|
|
|
gocryptfs -q -extpass "echo test" "$SSHFS_TMP/gocryptfs.crypt" gocryptfs.mnt
|
2020-05-24 14:52:09 +02:00
|
|
|
echo "gocryptfs mounted: $SSHFS_TMP/gocryptfs.crypt -> gocryptfs.mnt"
|
|
|
|
}
|
|
|
|
|
2021-08-31 19:01:47 +02:00
|
|
|
etime() {
|
2020-05-24 14:52:09 +02:00
|
|
|
T=$(/usr/bin/time -f %e -o /dev/stdout "$@")
|
2020-06-06 12:12:14 +02:00
|
|
|
LC_ALL=C printf %20.2f "$T"
|
2020-05-24 14:52:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MYNAME=$(basename "$0")
|
|
|
|
HOST=$1
|
|
|
|
|
|
|
|
prepare_mounts
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "$MYNAME: sshfs gocryptfs-on-sshfs"
|
|
|
|
echo -n "git init "
|
2020-05-24 22:02:34 +02:00
|
|
|
etime git init -q "$SSHFS_TMP/git1"
|
2020-05-24 14:52:09 +02:00
|
|
|
etime git init -q gocryptfs.mnt/git1
|
|
|
|
echo
|
|
|
|
|
|
|
|
git init -q git2
|
|
|
|
echo -n "rsync "
|
2020-05-24 22:02:34 +02:00
|
|
|
etime rsync -a --no-group git2 "$SSHFS_TMP"
|
2020-05-24 14:52:09 +02:00
|
|
|
etime rsync -a --no-group git2 gocryptfs.mnt
|
|
|
|
echo
|
2020-05-24 22:02:34 +02:00
|
|
|
|
|
|
|
echo -n "rm -R "
|
|
|
|
etime rm -R "$SSHFS_TMP/git1" "$SSHFS_TMP/git2"
|
|
|
|
etime rm -R gocryptfs.mnt/git1 gocryptfs.mnt/git2
|
|
|
|
echo
|
|
|
|
|
|
|
|
echo -n "mkdir "
|
|
|
|
pushd "$SSHFS_TMP" > /dev/null
|
|
|
|
etime mkdir $(seq 1 20)
|
|
|
|
popd > /dev/null
|
|
|
|
cd gocryptfs.mnt
|
|
|
|
etime mkdir $(seq 1 20)
|
|
|
|
cd ..
|
|
|
|
echo
|
|
|
|
|
|
|
|
echo -n "rmdir "
|
|
|
|
pushd "$SSHFS_TMP" > /dev/null
|
|
|
|
etime rmdir $(seq 1 20)
|
|
|
|
popd > /dev/null
|
|
|
|
cd gocryptfs.mnt
|
|
|
|
etime rmdir $(seq 1 20)
|
|
|
|
cd ..
|
|
|
|
echo
|
|
|
|
|
|
|
|
echo -n "touch "
|
|
|
|
pushd "$SSHFS_TMP" > /dev/null
|
|
|
|
etime touch $(seq 101 120)
|
|
|
|
popd > /dev/null
|
|
|
|
cd gocryptfs.mnt
|
|
|
|
etime touch $(seq 101 120)
|
|
|
|
cd ..
|
|
|
|
echo
|
|
|
|
|
|
|
|
echo -n "rm "
|
|
|
|
pushd "$SSHFS_TMP" > /dev/null
|
|
|
|
etime rm $(seq 101 120)
|
|
|
|
popd > /dev/null
|
|
|
|
cd gocryptfs.mnt
|
|
|
|
etime rm $(seq 101 120)
|
|
|
|
cd ..
|
|
|
|
echo
|