Guillaume Lambert | d9017ef | 2021-03-08 21:38:31 +0100 | [diff] [blame] | 1 | #!/bin/sh |
Roger Maitland | eb412c6 | 2018-05-31 14:09:09 -0400 | [diff] [blame] | 2 | |
| 3 | usage () { |
| 4 | echo "Usage:" |
| 5 | echo " ./$(basename $0) node1_ip node2_ip ... nodeN_ip" |
| 6 | exit 1 |
| 7 | } |
| 8 | |
| 9 | if [ "$#" -lt 1 ]; then |
| 10 | echo "Missing NFS slave nodes" |
| 11 | usage |
| 12 | fi |
| 13 | |
| 14 | #Install NFS kernel |
| 15 | sudo apt-get update |
| 16 | sudo apt-get install -y nfs-kernel-server |
| 17 | |
| 18 | #Create /dockerdata-nfs and set permissions |
| 19 | sudo mkdir -p /dockerdata-nfs |
| 20 | sudo chmod 777 -R /dockerdata-nfs |
| 21 | sudo chown nobody:nogroup /dockerdata-nfs/ |
| 22 | |
| 23 | #Update the /etc/exports |
| 24 | NFS_EXP="" |
| 25 | for i in $@; do |
Guillaume Lambert | d9017ef | 2021-03-08 21:38:31 +0100 | [diff] [blame] | 26 | NFS_EXP="${NFS_EXP}$i(rw,sync,no_root_squash,no_subtree_check) " |
Roger Maitland | eb412c6 | 2018-05-31 14:09:09 -0400 | [diff] [blame] | 27 | done |
| 28 | echo "/dockerdata-nfs "$NFS_EXP | sudo tee -a /etc/exports |
| 29 | |
| 30 | #Restart the NFS service |
| 31 | sudo exportfs -a |
| 32 | sudo systemctl restart nfs-kernel-server |