首页 > 其他 > 详细

玩具脚本-----yum源

时间:2014-03-18 10:16:23      阅读:528      评论:0      收藏:0      [点我收藏+]

其实还有很多不足的地方,bug还是比较多的

#!/bin/bash
#author joe
#description this shell is to create the yum repofile
Path="/etc/yum.repos.d/"
Name=".repo"
declare -i Enabled
declare -i Gpgcheck
file_exit(){
if [ $1 == "quit" ];then
exit 5
fi
}
check_name() {
file_exit $1
local filename=$1
if [  -e $Path$filename$Name ];then
read -p "do you want to add some thing in this repofile?(y/n):" answer
if [ $answer == "y" ];then
return 4
else
read -p "the $filename is exist" filename
return 3
fi
else
touch $Path$filename$Name
fi
}
check_file_thing() {
local filename=$1
read -p "1.insert the repo id:" Id
file_exit $Id
while :
do
read -p "2.insert the repo baseurl:" Baseurl
curl -m1  $Baseurl &>/dev/null
if [ $? -eq 0 ];then
break
else
echo "the error baseurl you insert,please do again!"
continue
fi
done
read -p "3.insert the enabled of the repo(enabled=0):" Enabled
read -p "4.insert the gpgcheck of the repo(gpgcheck=0):" Gpgcheck
echo "[$Id]" >>  $Path$filename$Name
echo "baseurl=$Baseurl" >> $Path$filename$Name
echo "enabled=$Enabled" >> $Path$filename$Name
echo "gpgcheck=$Gpgcheck" >> $Path$filename$Name
}
read -p "insert the file name:" filename
check_name $filename
while [ $? -eq 3 ]
do
read -p "insert the file name:" filename
check_name $filename
done
check_file_thing $filename
while :
do
yum repolist
if [ $? -eq 0 ];then
echo "the repo file fixed finished "
break
else
echo "you file repofile have something wrong!"
sleep 1
vim + $Path$filename$Name
fi
done

 

本文出自 “linux学习” 博客,请务必保留此出处http://joe51cto.blog.51cto.com/7680547/1378274

玩具脚本-----yum源,布布扣,bubuko.com

玩具脚本-----yum源

原文:http://joe51cto.blog.51cto.com/7680547/1378274

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!