Please grant the relevant permission on the shell scripts
./client_Export.sh
Takes three argument as follows
1. server ip address to be exported
2. client directory which should be exported to the particular server
3. options aka permission for the expoted folder
rw: This option allows the client server to both read and write within the shared directory
sync: Sync confirms requests to the shared directory only once the changes have been committed.
no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger filesystem, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
no_root_squash: This phrase allows root to connect to the designated directory
Eg:-:
[root@localhost ~]# ./clint_Export.sh 192.168.1.78 /home/cli rw,sync,no_root_squash,no_subtree_check
./server_Mount.sh
Takes three argument as follows
1. client (Provider of the Shared file) ip address
2. client directory which has exported to the server
3. server directory which client's directory to be mounted
Eg:-
[root@localhost ~]# ./server_Mount.sh 192.168.1.78 /home/cli /home/cliatserver
#client_Export.sh
#!/bin/sh
echo Author krishan thisera @iPhonik.com
if [ "$#" != 3 ]
then
echo
echo "Usage $0 <Where to export:ServerIP> <What should export:Exporting Dirctory> <Set permission>"
echo "Please reffer : https://github.com/krishanthisera/Share-A-Directory-between-two-server-NFS"
echo
exit 1
fi
ipaddr=$1
dir=$2
opt=$3
echo "Checking nfs-utils"
if ! rpm -qa | grep -qw nfs-utils; then
echo "Installing nfs-utils"
yum install nfs-utils
else
echo "nfs-utils Installed. Nothing to DO"
fi
echo "Checking nfs-utils-lib"
if ! rpm -qa | grep -qw nfs-utils-lib; then
echo "Installing nfs-utils"
yum install nfs-utils-lib
else
echo "nfs-utils-lib Installed. Nothing to DO"
fi
chkconfig --levels 235 nfs on
/etc/init.d/nfs start
if [ -d "$dir" ]; then
echo "$dir Found"
else
echo "Creating a new directory.."
mkdir "$dir"
chown 65534:65534 "$dir"
chmod 777 "$dir"
echo "Directory created.."
fi
echo "Updating Export Script..."
echo "$dir" " " " " "$ipaddr""("$opt")" >> /etc/exports
exportfs -a
echo "Export Script Updated..."
#server_Mount.sh
#!/bin/sh
if [ "$#" != 3 ]
then
echo
echo "Usage $0 <What is the source(Mount From):Clientip> <What is to mount:What is the client directory to be mount> <Where to Mount>"
echo "Please reffer : https://github.com/krishanthisera/Share-A-Directory-between-two-server-NFS"
echo
exit 1
fi
echo Author krishan thisera @iPhonik.com
ipaddr=$1
clidir=$2
srvdir=$3
echo "Checking nfs-utils"
if ! rpm -qa | grep -qw nfs-utils; then
echo "Installing nfs-utils"
yum install nfs-utils
else
echo "nfs-utils Installed. Nothing to DO"
fi
echo "Checking nfs-utils-lib"
if ! rpm -qa | grep -qw nfs-utils-lib; then
echo "Installing nfs-utils"
yum install nfs-utils-lib
else
echo "nfs-utils-lib Installed. Nothing to DO"
fi
chkconfig --levels 235 nfs on
/etc/init.d/nfs start
if [ -d "$srvdir" ]; then
echo "$srvdir Found"
else
echo "Creating a new directory.."
mkdir -p "$srvdir"
chown 65534:65534 "$srvdir"
chmod 777 "$srvdir"
echo "Directory created.."
fi
echo "Mounting $clidir in $srvdir"
mount "$ipaddr"":""$clidir" """$srvdir"
echo "Mounted $clidir to $srvdir"
df -h
Comments
Post a Comment