lots: shellcheck, streaming stuff, fixes
[distro-setup] / demohost-mount
1 #!/bin/bash
2 # shellcheck source=/a/bin/ds/.bashrc
3 if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
4
5 [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
6
7
8
9
10 ip=$(host demohost | sed -rn 's/^\S+ has address //p;T;q')/32
11 cedit demohost /etc/exports <<EOF || exportfs -ra
12 /a $ip(async,rw,no_subtree_check,no_root_squash)
13 /q $ip(async,rw,no_subtree_check,no_root_squash)
14 EOF
15
16
17 ssh root@demohost bash -s <<'EOFOUTER'
18 set -eE -o pipefail
19
20 apt-get install -y nfs-common
21
22 sed -ri '\%^(faiserver:/[aq]|/q/p)\s%d' /etc/fstab
23 cat >>/etc/fstab <<'EOF'
24 faiserver:/a /a nfs defaults 0 0
25 faiserver:/q /q nfs defaults 0 0
26 /q/p /p none bind 0 0
27 EOF
28
29 mkdir -p /a /q /p
30 mount /a
31 mount /q
32 mount /p
33 EOFOUTER