标签:for font parameter base -- echo size cti make
+++++++++++++++++++++++++++++++++
内容:shell 脚本实战之配置网络YUM源及epel源
时间:2019年8月5日
+++++++++++++++++++++++++++++++++
#!/usr/bin/env bash
yum_dir=/etc/yum.repos.d
yum_bak_dir=/etc/yum.repos.d/bak
centos6_repo_pos=http://mirrors.aliyun.com/repo/Centos-6.repo
centos6_epel_pos=http://mirrors.aliyun.com/repo/epel-6.repo
centos7_repo_pos=http://mirrors.aliyun.com/repo/Centos-7.repo
centos7_epel_pos=http://mirrors.aliyun.com/repo/epel-7.repo
function menu ()
{
cat <<-EOF
+--------------------------------------------------+
| Yum source configure menu |
| |
| 1. Yum source for CentOS 6.X |
| |
| 2. Yum source for CentOS 6.X (epel) |
| |
| 3. Yum source for CentOS 7.X |
| |
| 4. Yum source for CentOS 7.X (epel) |
| |
| 5. to help menu |
| |
| 6. exits for Yum source config |
| |
+--------------------------------------------------+
EOF
}
function get_parameter ()
{
echo -ne "\e[0;34mPlease input action : \e[1;0m";read action
}
function yum_repo_bak ()
{
if [ ! -d $yum_bak_dir ] ; then
mkdir -p $yum_bak_dir
fi
/bin/mv $yum_dir/*.repo $yum_bak_dir
}
function get_repo ()
{
if [ $action -eq 1 ] ; then
curl -o $yum_dir/CentOS-Base.repo $centos6_repo_pos &>/dev/null
elif [ $action -eq 2 ] ; then
curl -o $yum_dir/epel.repo $centos6_epel_pos &>/dev/null
elif [ $action -eq 3 ] ; then
curl -o $yum_dir/CentOS-Base.repo $centos7_repo_pos &>/dev/null
elif [ $action -eq 4 ] ; then
curl -o $yum_dir/epel.repo $centos7_epel_pos &>/dev/null
fi
# make cache
# yum clean all &>/dev/null
# yum makechache &>/dev/null
}
# call function
yum_repo_bak
menu
while :
do
get_parameter
case $action in
1 | 2 | 3 | 4)
get_repo
if [ $? -eq 0 ] ; then
echo -e "\e[1;31mrepo file is download!\e[1;0m"
fi
continue ;;
5)
menu ;;
6)
exit ;;
*)
echo -e "\e[1;31mInvalid input parameter!\e[1;0m"
esac
done
标签:for font parameter base -- echo size cti make
原文地址:https://www.cnblogs.com/lv1572407/p/11306309.html