Tomáš Levora | f0c81b0 | 2018-12-20 09:45:02 +0100 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | # COPYRIGHT NOTICE STARTS HERE |
| 4 | # |
| 5 | # Copyright 2018 © Samsung Electronics Co., Ltd. |
| 6 | # |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | # you may not use this file except in compliance with the License. |
| 9 | # You may obtain a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | # See the License for the specific language governing permissions and |
| 17 | # limitations under the License. |
| 18 | # |
| 19 | # COPYRIGHT NOTICE ENDS HERE |
| 20 | |
| 21 | |
| 22 | usage () { |
| 23 | echo "Usage:" |
| 24 | echo " ./$(basename $0) node1_ip node2_ip ... nodeN_ip" |
| 25 | exit 1 |
| 26 | } |
| 27 | |
| 28 | if [ "$#" -lt 1 ]; then |
| 29 | echo "Missing NFS slave nodes" |
| 30 | usage |
| 31 | fi |
| 32 | |
| 33 | #Install NFS kernel |
| 34 | #sudo apt-get update |
| 35 | #sudo apt-get install -y nfs-kernel-server |
| 36 | |
| 37 | #Create /dockerdata-nfs and set permissions |
| 38 | sudo mkdir -p /dockerdata-nfs |
| 39 | sudo chmod 777 -R /dockerdata-nfs |
| 40 | sudo chown nobody:nobody /dockerdata-nfs/ |
| 41 | |
| 42 | #Update the /etc/exports |
| 43 | NFS_EXP="" |
| 44 | for i in $@; do |
| 45 | NFS_EXP+="$i(rw,sync,no_root_squash,no_subtree_check) " |
| 46 | done |
| 47 | echo "/dockerdata-nfs "$NFS_EXP | sudo tee -a /etc/exports |
| 48 | |
| 49 | #Restart the NFS service |
| 50 | sudo exportfs -a |
| 51 | sudo systemctl restart nfs-server |