您的位置:首页 > 运维架构 > Shell

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: