2016-06-08 22:38:14 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Mounts two gocryptfs filesystems, "ping" and "pong" and moves the
|
|
|
|
# linux-3.0 kernel tree back and forth between them.
|
|
|
|
#
|
|
|
|
# When called as "pingpong-rsync.bash" it uses "rsync --remove-source-files"
|
|
|
|
# for moving the files, otherwise plain "mv".
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
2020-07-26 19:55:17 +02:00
|
|
|
# Run at low priority to not annoy the user too much
|
|
|
|
renice 19 $$
|
|
|
|
|
2016-06-08 22:38:14 +02:00
|
|
|
cd "$(dirname "$0")"
|
|
|
|
MD5="$PWD/linux-3.0.md5sums"
|
2021-08-31 19:01:47 +02:00
|
|
|
MYNAME=$(basename "$0")
|
2017-02-15 23:02:01 +01:00
|
|
|
source ../fuse-unmount.bash
|
2016-06-08 22:38:14 +02:00
|
|
|
|
|
|
|
# Setup
|
2018-03-07 09:45:20 +01:00
|
|
|
../dl-linux-tarball.bash
|
2016-06-08 22:38:14 +02:00
|
|
|
cd /tmp
|
|
|
|
|
|
|
|
PING=$(mktemp -d ping.XXX)
|
|
|
|
PONG=$(mktemp -d pong.XXX)
|
2021-08-31 19:01:47 +02:00
|
|
|
mkdir "$PING.mnt" "$PONG.mnt"
|
2016-06-08 22:38:14 +02:00
|
|
|
|
|
|
|
# Cleanup trap
|
|
|
|
# Note: gocryptfs may have already umounted itself because bash relays SIGINT
|
2017-02-15 23:02:01 +01:00
|
|
|
# Just ignore unmount errors.
|
|
|
|
trap "set +e ; cd /tmp; fuse-unmount -z $PING.mnt ; fuse-unmount -z $PONG.mnt ; rm -rf $PING $PONG $PING.mnt $PONG.mnt" EXIT
|
2016-06-08 22:38:14 +02:00
|
|
|
|
2021-08-31 19:01:47 +02:00
|
|
|
gocryptfs -q -init -extpass="echo test" -scryptn=10 "$PING"
|
|
|
|
gocryptfs -q -init -extpass="echo test" -scryptn=10 "$PONG"
|
2016-06-08 22:38:14 +02:00
|
|
|
|
2021-08-31 19:01:47 +02:00
|
|
|
gocryptfs -q -extpass="echo test" -nosyslog "$PING" "$PING.mnt"
|
|
|
|
gocryptfs -q -extpass="echo test" -nosyslog "$PONG" "$PONG.mnt"
|
2016-06-08 22:38:14 +02:00
|
|
|
|
|
|
|
echo "Initial extract"
|
2021-08-31 19:01:47 +02:00
|
|
|
tar xf /tmp/linux-3.0.tar.gz -C "$PING.mnt"
|
2016-06-08 22:38:14 +02:00
|
|
|
|
2021-08-31 19:01:47 +02:00
|
|
|
move_and_md5() {
|
|
|
|
if [ "$MYNAME" = "pingpong-rsync.bash" ]; then
|
2016-06-08 22:38:14 +02:00
|
|
|
echo -n "rsync "
|
2021-08-31 19:01:47 +02:00
|
|
|
rsync -a --remove-source-files "$1" "$2"
|
|
|
|
find "$1" -type d -delete
|
2016-06-08 22:38:14 +02:00
|
|
|
else
|
|
|
|
echo -n "mv "
|
2021-08-31 19:01:47 +02:00
|
|
|
mv "$1" "$2"
|
2016-06-08 22:38:14 +02:00
|
|
|
fi
|
2021-08-31 19:01:47 +02:00
|
|
|
if [ -e "$1" ]; then
|
2016-06-08 22:38:14 +02:00
|
|
|
echo "error: source directory $1 was not removed"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-08-31 19:01:47 +02:00
|
|
|
cd "$2"
|
2016-06-08 22:38:14 +02:00
|
|
|
echo -n "md5 "
|
2021-08-31 19:01:47 +02:00
|
|
|
md5sum --status -c "$MD5"
|
2016-06-08 22:38:14 +02:00
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
|
|
|
N=1
|
|
|
|
while true; do
|
|
|
|
echo -n "$N: "
|
2021-08-31 19:01:47 +02:00
|
|
|
move_and_md5 "$PING.mnt/linux-3.0" "$PONG.mnt"
|
|
|
|
move_and_md5 "$PONG.mnt/linux-3.0" "$PING.mnt"
|
2016-06-08 22:38:14 +02:00
|
|
|
date +%H:%M:%S
|
2021-08-31 19:01:47 +02:00
|
|
|
N=$((N+1))
|
2016-06-08 22:38:14 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
wait
|