使用Shall脚本搭建NFS
程序员文章站
2022-03-26 19:01:43
#!/bin/bashecho '1,checking network... 'ping -c1 192.168.1.51 &> /dev/nullif [ $? -eq 0 ];then echo 'network is ok!'else echo 'network is not ok! ' exit 1fiecho '2.Configure selinux and firewalld... 'setenforce 0 &> /dev/nullech...
#!/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
下一篇: Ajax异步请求PHP数据