This paper introduces an example of how shell scripts can build NFS services automatically. The details are as follows:
#!/bin/bash #name:zidong_dajian_nfs_fuwu.sh #path:/sh/ #update:2017-9-17 #Test whether the network is smooth Ping - C 1 172.16.13.254 > / dev / null********** #Step 1: shut down SELinux and firewall Setenforce 0 > / dev / null & echo********** Systemctl stop firewall > / dev / null & echo********** #Step 2: confirm whether the software is installed rpm -aq rpcbind >/dev/null if [ $? -eq 0 ];then Echo "rpcbind software installed" else Yum install rpcbind - Y > / dev / null & echo "installing software" fi Echo software installed********** #Step 3: create and publish the shared directory Please enter the directory you want to share: "dir mkdir $dir -p >/dev/null chmod 1777 $dir Read - P "please enter the network segment to be shared" WD Please enter the permission mode to share, enter ro or RW: "QX cat >> /etc/exports << end $dir $wd($qx) end #Step 4: start the service and start it automatically systemctl restart rpcbind.service systemctl restart nfs.service Echo "NFS sharing service has been set up, welcome to use it next time"
Test: after the NFS server executes the script, first check whether the shared directory is successfully generated, and then touch a file in it for testing
The test side uses the showmount command to view the shared directory of the server, and then mounts it to a local directory of its own, and then goes in to see if there are corresponding files and check its contents
This article about shell script automatic build NFS service example article introduced here, more related shell automatic build NFS content, please search the previous articles of developeppaer or continue to browse the related articles below, I hope you can support developeppaer more in the future!