搭建nfs服务的shell script
2012-08-27 00:00
316 查看
#!/bin/bash
#Shell name: conf_nfs.sh
#
#Program:
# configer nsf
#Author:pero
#Email: perofu.com@gmail.com
#History:
# 2012/7/24
#
#Usage: vi conf_nfs.sh :set ff=unix
#
#If you have any opinion please contact me
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:.
export PATH
soft=$(rpm -qa |grep nfs |wc -l)
if [ $UID -ne 0 ]
then
echo "Runing as root"
exit 77
fi
read -p "Please input a real dir in you system to share:" dir
read -p "Please input a subnet like (10.0.0.0/24) to share with net:" net
if [ ! -d $dir ]
then
echo "dir not found"
exit 77
fi
if [ $soft -lt 2 ]
then
yum install nfs-utils-* -y
fi
file=/etc/exports
if [ -f $file ]
then
echo "$dir $net(ro,sync)" >> $file
else
touch $file
echo "$dir $net(ro,sync)" >> $file
fi
/etc/init.d/nfs restart &> /dev/null
if [ $? -eq 0 ]
then
echo "nfs service is start..."
exportfs -v
else
echo "Please check are you $net right? "
exit 77
fi
#Shell name: conf_nfs.sh
#
#Program:
# configer nsf
#Author:pero
#Email: perofu.com@gmail.com
#History:
# 2012/7/24
#
#Usage: vi conf_nfs.sh :set ff=unix
#
#If you have any opinion please contact me
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:.
export PATH
soft=$(rpm -qa |grep nfs |wc -l)
if [ $UID -ne 0 ]
then
echo "Runing as root"
exit 77
fi
read -p "Please input a real dir in you system to share:" dir
read -p "Please input a subnet like (10.0.0.0/24) to share with net:" net
if [ ! -d $dir ]
then
echo "dir not found"
exit 77
fi
if [ $soft -lt 2 ]
then
yum install nfs-utils-* -y
fi
file=/etc/exports
if [ -f $file ]
then
echo "$dir $net(ro,sync)" >> $file
else
touch $file
echo "$dir $net(ro,sync)" >> $file
fi
/etc/init.d/nfs restart &> /dev/null
if [ $? -eq 0 ]
then
echo "nfs service is start..."
exportfs -v
else
echo "Please check are you $net right? "
exit 77
fi
相关文章推荐
- NFS(文件共享)服务搭建与配置
- NfS服务的搭建
- 一步步搭建NFS服务(1)------理论预备知识
- 一步步搭建NFS服务(2)------安装和配置
- linux下网络文件系统NFS服务的搭建
- RHEL6.4 NFS文件共享服务搭建
- Linux6.5中搭建NFS服务,远程存储数据。
- ubuntu下nfs服务的搭建-AMR板挂载
- shell script自动搭建简单的nfs服务器
- linux下搭建NFS服务(指定WWW用户)
- centos6.5 搭建NFS 服务
- 在Rhel 6.3下 搭建heartbeat + drbd + NFS 服务
- NFS服务搭建与配置
- NFS服务搭建与配置
- RHCE7.0-搭建基于NFS网络文件系统服务
- NFS服务搭建
- ubuntu开启nfs服务,并搭建gdbserver
- exportfs命令、NFS客户端问题、FTP介绍、使用vsftpd搭建ftp服务
- day 56 NFS服务搭建(续)与FTP服务搭建与配置
- 【Ubuntu】 Ubuntu16.04搭建NFS服务