File: eval_under_nfs

package info (click to toggle)
datalad 1.1.5-2.1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 7,140 kB
  • sloc: python: 69,392; sh: 1,521; makefile: 220
file content (45 lines) | stat: -rwxr-xr-x 943 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# Evaluate given command while running with DATALAD_TESTS_TEMP_DIR pointing to
# that temporary filesystem mounted using nfs

set -e

fs=nfs
# TODO: nfs and mount options?

set -u
tmp=$(mktemp -u "${TMPDIR:-/tmp}/datalad-nfs-XXXXX")


uid=$(id -u)
mntorig="$tmp.orig"
mntpoint="$tmp.nfs"

echo "I: mounting $mntorig under $mntpoint via $fs"

set -x

mkdir -p "$mntpoint"
mkdir -p "$mntorig"

if ! dpkg -l nfs-kernel-server | grep '^ii.*nfs-kernel-server'; then
    sudo apt-get install -y nfs-kernel-server
fi

sudo exportfs -o rw "localhost:$mntorig"
sudo mount -t "$fs" "localhost:$mntorig" "$mntpoint"

# should how it was mounted
sudo mount | grep "$mntpoint" | sed -e 's,^,I: ,g'

# Run the actual command
echo "I: running $@"
TMPDIR="$mntpoint" DATALAD_TESTS_TEMP_DIR="$mntpoint" "$@"
ret=$?

echo "I: done, unmounting"
sudo umount "$mntpoint"
sudo exportfs -u "localhost:$mntorig"

rm -rf "$mntpoint" "$mntorig"
exit "$ret"