-#!/bin/bash
+#!/bin/bash -l
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
[[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@"
-virsh destroy demohost ||:
-# there's some other ways to configure it, but by default, we get perms of this user
-usermod -a -G ian libvirt-qemu
-usermod -a -G traci libvirt-qemu
-virsh attach-device demohost <(e "<filesystem type='mount' accessmode='mapped'> <source dir='/q'/> <target dir='/q'/> </filesystem>") --config ||:
-virsh attach-device demohost <(e "<filesystem type='mount' accessmode='mapped'> <source dir='/a'/> <target dir='/a'/> </filesystem>") --config ||:
+ip=$(host demohost | sed -rn 's/^\S+ has address //p;T;q')/32
+cedit demohost /etc/exports <<EOF || exportfs -ra
+/a $ip(async,rw,no_subtree_check,no_root_squash)
+/q $ip(async,rw,no_subtree_check,no_root_squash)
+EOF
-virsh start demohost
-while ! timeout -s 9 5 ssh demohost :; do sleep 3; done
ssh root@demohost bash -s <<'EOFOUTER'
set -eE -o pipefail
-cat >>/etc/modules <<EOF
-loop
-virtio
-9p
-9pnet
-9pnet_virtio
-EOF
-service kmod start
+apt-get install -y nfs-common
+sed -ri '\%^(faiserver:/[aq]|/q/p)\s%d' /etc/fstab
cat >>/etc/fstab <<'EOF'
-/a /a 9p trans=virtio 0 0
-/q /q 9p trans=virtio 0 0
+faiserver:/a /a nfs defaults 0 0
+faiserver:/q /q nfs defaults 0 0
/q/p /p none bind 0 0
EOF
+
mkdir -p /a /q /p
mount /a
mount /q