搭建磁盘配额的shell script
2012-08-27 00:00
134 查看
#!/bin/bash
#
#Shell name:quota.sh
#
#Program:
# create disk-quotas for some users
#Author:pero
#Email: perofu.com@gmail.com
#History:
# 2012/07/18
#Usage:vi quota.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
if [ $UID -ne 0 ]
then
echo "Run as root"
exit 1
fi
#check the soft do you have
soft=$(rpm -qa | grep quota)
file=fstab
temp=tmp.fs
if [ -z $soft ]
then
yum install quota -y &> //nulldev
echo "the soft of quota is install"
else
echo "the soft of quota was install"
fi
#config the /etc/fstab
read -p "please input a 'Mounted on' for check the partition :" mou
read -p "please input a user name to creating disk-quotas:" user
par=$(df -h | grep $mou | gawk '{print $1}')
cd /etc
cp -p $file $file.bak
mv $file $temp
n=$(grep -n $mou $temp | gawk 'BEGIN{FS=":"} {print $1}')
if [ -z $n ]
then
echo "$mou is not in you /etc/fstab file"
echo "please input a right 'Mounted on' "
else
sed ''$n's/defaults/defaults,usrquota,grpquota/' $temp > $file
if [ $? -eq 0 ]
then
rm -rf $temp
echo "writed config in /etc/fstab"
mount -o remount,usrquota,grpquota $mou
cd $mou
#quotacheck -ugcv $mou &> /dev/null
quotacheck -ugcva &> /dev/null
echo "please use Usage:edquota -u user to create disk-quotas"
echo "if you want to use some one who had created disk-quotas as a template to creating more users disk-quotas "
echo "please do this [./cpm_quota.sh]"
else
echo "please in put a right 'Mounted on' "
mv $temp $file
rm -rf $file.bak
#exit 0
fi
fi
#
#Shell name:quota.sh
#
#Program:
# create disk-quotas for some users
#Author:pero
#Email: perofu.com@gmail.com
#History:
# 2012/07/18
#Usage:vi quota.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
if [ $UID -ne 0 ]
then
echo "Run as root"
exit 1
fi
#check the soft do you have
soft=$(rpm -qa | grep quota)
file=fstab
temp=tmp.fs
if [ -z $soft ]
then
yum install quota -y &> //nulldev
echo "the soft of quota is install"
else
echo "the soft of quota was install"
fi
#config the /etc/fstab
read -p "please input a 'Mounted on' for check the partition :" mou
read -p "please input a user name to creating disk-quotas:" user
par=$(df -h | grep $mou | gawk '{print $1}')
cd /etc
cp -p $file $file.bak
mv $file $temp
n=$(grep -n $mou $temp | gawk 'BEGIN{FS=":"} {print $1}')
if [ -z $n ]
then
echo "$mou is not in you /etc/fstab file"
echo "please input a right 'Mounted on' "
else
sed ''$n's/defaults/defaults,usrquota,grpquota/' $temp > $file
if [ $? -eq 0 ]
then
rm -rf $temp
echo "writed config in /etc/fstab"
mount -o remount,usrquota,grpquota $mou
cd $mou
#quotacheck -ugcv $mou &> /dev/null
quotacheck -ugcva &> /dev/null
echo "please use Usage:edquota -u user to create disk-quotas"
echo "if you want to use some one who had created disk-quotas as a template to creating more users disk-quotas "
echo "please do this [./cpm_quota.sh]"
else
echo "please in put a right 'Mounted on' "
mv $temp $file
rm -rf $file.bak
#exit 0
fi
fi
相关文章推荐
- linux下搭建NFS文件服务器及磁盘配额 A
- Linux NFS服务器的搭建与磁盘配额管理方案的实施 推荐
- linux下搭建NFS文件服务器及磁盘配额 B
- shell script自动搭建简单的nfs服务器
- 按照某一固定用户的磁盘配额增加用户的shell script
- linux下搭建NFS文件服务器及磁盘配额 C
- shell script自动搭建简单的pxe服务器
- Llinux 磁盘配额的搭建和常规问题解答
- shell script自动搭建简单的cacti监控
- shell script自动搭建简单的mail服务器(postfix+dovecot)
- 搭建ssh无密码远程登录的安全(ssl)shell script
- shell script自动搭建简单的yum
- shell script自动搭建简单的双机ssh认证
- shell script自动搭建简单的quota(磁盘配额)
- shell script自动搭建简单的mysql主从(replication)
- 搭建nfs服务的shell script
- 搭建ISCSI服务的shell script
- 搭建dhcp的shell script
- ThinkPHP学习(一)开发环境搭建
- nfs服务器搭建