minor fix and add automatic updates
[distro-setup] / demohost-mount
1 #!/bin/bash -l
2 set -eE -o pipefail
3 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
4
5
6 [[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@"
7
8
9
10
11 ip=$(host demohost | sed -rn 's/^\S+ has address //p;T;q')/32
12 cedit demohost /etc/exports <<EOF || exportfs -ra
13 /a $ip(async,rw,no_subtree_check,no_root_squash)
14 /q $ip(async,rw,no_subtree_check,no_root_squash)
15 EOF
16
17
18 ssh root@demohost bash -s <<'EOFOUTER'
19 set -eE -o pipefail
20
21 apt-get install -y nfs-common
22
23 sed -ri '\%^(faiserver:/[aq]|/q/p)\s%d' /etc/fstab
24 cat >>/etc/fstab <<'EOF'
25 faiserver:/a /a nfs defaults 0 0
26 faiserver:/q /q nfs defaults 0 0
27 /q/p /p none bind 0 0
28 EOF
29
30 mkdir -p /a /q /p
31 mount /a
32 mount /q
33 mount /p
34 EOFOUTER