Shell script: auto-build Yum (upgrade version)

Source: Internet
Author: User
Tags yum repolist

前面写过关于自动搭建yum的脚本,感觉不够完善。下面这个脚本在前面的基础上加上判断,如果yum已经搭建好,那么不安装;没有搭建则安装。

1[[email protected] ~]# vim testyum.sh
Script Content
#!/bin/bash
n=yum repolist | grep ‘repolist‘| awk ‘{print $2}‘
If [$ (N))-GT 0]; Then
echo "Yum source already Installed"
Exit
elif [$ ((N))-eq 0];then
rm-rf/etc/yum.repos.d/*
echo "[+] //Note from the start of this line to Gpgcheck=0 to write the head, if not, then the Yum file will produce a malformed
name=110
Baseurl=http://192.168.4.254/rhel7
Enabled=1
Gpgcheck=0 ">/etc/yum.repos.d/110.repo
Yum Clean all &>/dev/null
echo "Yum has been built"
echo "Shared packages:"
Yum Repolist | Tail-1
Fi
[Email protected] ~]# chmod +x/root/testyum.sh

2 Testing
Already built the test
[Email protected] ~]#./testyum.sh
Yum Source is already installed

No test setup.
[Email protected] ~]# rm-rf/etc/yum.repos.d/*
[Email protected] ~]#./testyum.sh
Yum has been built to complete
Total Packages:
repolist:4,620

Shell script: auto-build Yum (upgrade version)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.