#!/bin/bash
echo '1,checking network... '
ping -c1 192.168.1.51 &> /dev/null
if [ $? -eq 0 ];then
echo 'network is ok!'
else
echo 'network is not ok! '
exit 1
fi
echo '2.Configure selinux and firewalld... '
setenforce 0 &> /dev/null
echo 'Selinux set disable'
systemctl stop firewalled &> /dev/null
echo 'firewalld stopped'
echo '3.Check rpcbind...'
rpm -q rpcbind &> /dev/null
if [ $? -eq 0 ];then
echo 'rpcbind has installed!'
else
yum install -y rpcbind &> /dev/null && echo 'rpcbind install successfully' || echo 'rpcbind install failed!'; exit 1
fi
echo '4.Creat Share Dir and Share...'
read -p "Please input share dir:" dir
if [ -e $dir ];then
echo "Share Directory $dir exists!"
else
mkdir -p $dir
echo "Share Directory $dir creat success!"
fi
chmod 1777 $dir
read -p "Please input share subnet:" sub
read -p "Please input share permission(ro/rw): " permission
echo 'Edit nfs configure file /etc/exports'
read -p "input 1 for clear config , default is add: " choice
if [ $choice -eq 1 ];then
> /etc/exports
fi
cat >> /etc/exports <<EOF
$dir $sub($permission)
EOF
cho "5.Start and enable service..."
systemctl status nfs-server.service | grep active &>/dev/null
if [ $? -eq 0 ];then
echo 'nfs-server.servise is active , restarting now ...'
systemctl restart nfs-server.service
echo 'nfs-server.service is restart successfully!'
else
systemctl enable rpcbind --now
systemctl encble nfs-server.service --now
fi
echo 'NFS buids completed!'
本文地址:https://blog.csdn.net/qq_42564122/article/details/107385436
如对本文有疑问, 点击进行留言回复!!
如何在Ubuntu 18.04(实体机)上配置OpenWRT的开发环境
网友评论