Skip to content

Instantly share code, notes, and snippets.

@bzeron
Created July 6, 2019 06:24
Show Gist options
  • Save bzeron/50a6438210128cec7bfec7a49a7ec4c2 to your computer and use it in GitHub Desktop.
Save bzeron/50a6438210128cec7bfec7a49a7ec4c2 to your computer and use it in GitHub Desktop.
#!/bin/bash
read -p "centos install nfs, server is [s] and client is [c]: " TYPE
if [ "s" == "${TYPE}" ]; then
read -p "need close firewalld: " CLOSE_FIREWALLD
if [ -z "${CLOSE_FIREWALLD}" ]; then
systemctl stop firewalld
fi
read -p "need clese iptables: " CLOSE_IPTABLES
if [ -z "${CLOSE_IPTABLES}" ]; then
/etc/init.d/iptables stop
fi
yum -y install nfs-utils rpcbind
read -p "share dir: " SHARE_DIR
read -p "share client address: " SHARE_CLIENT_ADDRESS
read -p "share mod, default[rw,sync,no_root_squash]: " SHARE_MOD
echo "${SHARE_DIR} ${SHARE_CLIENT_ADDRESS}(${SHARE_MOD})" >/etc/exports
systemctl start rpcbind.service
systemctl start nfs-server.service
systemctl enable rpcbind.service
systemctl enable nfs-server.service
fi
if [ "c" == "${TYPE}" ]; then
yum -y install nfs-utils rpcbind
read -p "server ip: " SERVER_IP
showmount -e ${SERVER_IP}
read -p "server share dir: " SERVER_SHARE_DIR
read -p "client share dir: " CLIENT_SHARE_DIR
mkdir -p ${CLIENT_SHARE_DIR}
#mount ${SERVER_IP}:${SERVER_SHARE_DIR} ${CLIENT_SHARE_DIR}
#umount ${CLIENT_SHARE_DIR}
echo "${SERVER_SHARE_DIR}:${SERVER_SHARE_DIR} ${CLIENT_SHARE_DIR} nfs defaults 0 0" >>/etc/fstab
mount -a
df -hT
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment