NFS 共享过程脚本过程
Posted 123456likun
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NFS 共享过程脚本过程相关的知识,希望对你有一定的参考价值。
#!/bin/bash
#NFS 共享服务
#2019-8-25
#挂载光盘
d -p "请输入你的挂载点" dir
echo "正在挂载。。。。。"
mount | grep -q "/dev/sr0" && umount /dev/sr0
[ -d $dir ] || mkdir dir
mount /dev/sr0 $dir &> /dev/null
echo "挂载成功"
cd /etc/yum.repos.d/
[ -d likun ] || mkdir likun
mv C* likun
echo "正在挂载。。。。。"
mount | grep -q "/dev/sr0" && umount /dev/sr0
[ -d $dir ] || mkdir dir
mount /dev/sr0 $dir &> /dev/null
echo "挂载成功"
cd /etc/yum.repos.d/
[ -d likun ] || mkdir likun
mv C* likun
cat << EDF > local.repo
[xxx]
name=xxx
baseurl=file://$dir
enabled=1
gpgcheck=0
EDF
echo "清除小朋友"
yum clean all &> /dev/null
echo "构建轰趴基地yum"
yum makecache &> /dev/null
echo "构建成功"
[xxx]
name=xxx
baseurl=file://$dir
enabled=1
gpgcheck=0
EDF
echo "清除小朋友"
yum clean all &> /dev/null
echo "构建轰趴基地yum"
yum makecache &> /dev/null
echo "构建成功"
#准备环境
rpm -q nfs rpccbind &>/dev/null
yum -y install nfs-utills rpcbind &>/dev/null
echo "安装成功"
rpm -q nfs rpccbind &>/dev/null
yum -y install nfs-utills rpcbind &>/dev/null
echo "安装成功"
#启动服务
/etc/init.d/rpcbind start
/etc/init.d/nfs start
echo "启动成功"
/etc/init.d/rpcbind start
/etc/init.d/nfs start
echo "启动成功"
#建立挂载编写
mkdir /www
echo ‘test‘ >/www/index.html
cat << EDF >/etc/exports
/www 192.168.100.68(rw) 192.168.100.66(ro)
EDF
echo "配置成功"
mkdir /www
echo ‘test‘ >/www/index.html
cat << EDF >/etc/exports
/www 192.168.100.68(rw) 192.168.100.66(ro)
EDF
echo "配置成功"
#重启服务
/etc/init.d/nfs restart &> /dev/null
echo "重启成功"
/etc/init.d/nfs restart &> /dev/null
echo "重启成功"
#查看信息
showmount -e 192.168.100.68
showmount -e 192.168.100.68
#编辑DNCP中继器
#!/sbin/bash
echo "开启中继"
echo "关闭安全机制中。。。"
systemctl stop firewalld
iptables -F
setenforce 0
#!/sbin/bash
echo "开启中继"
echo "关闭安全机制中。。。"
systemctl stop firewalld
iptables -F
setenforce 0
#DHCP服务
echo "构建环境"
echo "DHCP安装中..."
yum -y install dhcp &>/dev/null
echo "构建环境"
echo "DHCP安装中..."
yum -y install dhcp &>/dev/null
echo "配置文件"
cat << EOF >> /etc/systemctl.conf
net.ipv4.ip _forward=1
EOF
cat << EOF >> /etc/systemctl.conf
net.ipv4.ip _forward=1
EOF
echo "中继路由启动"
sysctl -p
sysctl -p
read -p "DHCP服务器IP" lal
echo "开启转发"
dhcrelay $lal
echo "开启转发"
dhcrelay $lal
以上是关于NFS 共享过程脚本过程的主要内容,如果未能解决你的问题,请参考以下文章