Roger Maitland | eb412c6 | 2018-05-31 14:09:09 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 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 |
| 26 | NFS_EXP+="$i(rw,sync,no_root_squash,no_subtree_check) " |
| 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 |