shell script自动搭建简单的nfs服务器
2013-03-04 17:17
387 查看
#!/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
本文出自 “无咎” 博客,请务必保留此出处http://perofu.blog.51cto.com/6061242/1144579
#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
本文出自 “无咎” 博客,请务必保留此出处http://perofu.blog.51cto.com/6061242/1144579
相关文章推荐
- shell script自动搭建简单的pxe服务器
- shell script自动搭建简单的mail服务器(postfix+dovecot)
- hell script自动搭建简单的iscsi服务器
- NFS服务器的简单搭建教程
- shell script自动搭建简单的cacti监控
- Nfs服务器简单搭建
- 简单NFS服务器的搭建
- shell script自动搭建简单的yum
- 搭建NIS+NFS服务器并实现autofs自动挂载
- shell script自动搭建简单的双机ssh认证
- shell script自动搭建简单的mysql主从(replication)
- 简单搭建nfs文件共享服务器
- nfs服务器的简单搭建过程-记录方法
- shell script自动搭建简单的dhcp服务器
- linux下搭建NFS文件服务器及磁盘配额 A
- Go搭建简单服务器及http包源码分析
- linux服务___Linux下NFS服务器的搭建与配置
- nfs服务器的搭建与管理
- Win7系统下搭建NFS服务器
- Linux下NFS服务器搭建