zoukankan      html  css  js  c++  java
  • yum自动脚本

    echo -e "33[34mstop server:33[0m"
    service iptables stop
    service NetworkManager stop
    chkconfig --del iptables
    chkconfig --del NetworkManager
    setenforce 0
    cat /etc/redhat-release | cut -d' ' -f3 | cut -d. -f1 >/so.txt
    #read -p "Input source.1/2/3:" MI
    if [ $(cat /so.txt) -eq 6 ];then
            cd /etc/yum.repos.d/
            [ -f /etc/yum.repos.d/CentOS-Base.repo ] && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak && echo "backup local source OK!"
            [ -f /etc/yum.repos.d/CentOS6-Base.repo ] && echo "yum source exist" && yum list && exit 4
            [ ! -f /etc/yum.repos.d/CentOS6-Base.repo ] && wget http://10.56.126.75/.help/CentOS6-Base.repo
            [ -f /etc/yum.repos.d/CentOS6-Base.repo ] && yum clean all &>/dev/null && echo "Clean Yum cache OK" || echo "Loading error." 
            yum makecache
            yum list
            rm -rf /so.txt
    elif [ $(cat /so.txt) -eq 7 ];then
            cd /etc/yum.repos.d/
            [ -f /etc/yum.repos.d/CentOS-Base.repo ] && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak && echo "backup local source OK!"
            [ -f /etc/yum.repos.d/CentOS7-Base.repo ] && echo "yum source exist" && exit 4
            [ ! -f /etc/yum.repos.d/CentOS7-Base.repo ] && wget http://10.56.126.75/.help/CentOS7-Base.repo
            [ -f /etc/yum.repos.d/CentOS7-Base.repo ] && yum clean all &>/dev/null && echo "Clean Yum cache OK" || echo "Loading error." && exit 4
            echo "please waiting..." 
            yum makecahe
            yum list
            rm -rf /so.txt
    elif [ $(cat /so.txt) -eq 5 ];then
            [ -f /etc/yum.repos.d/CentOS-Base.repo ] && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak && echo "backup local source OK!"
            [ -f /etc/yum.repos.d/CentOS5-Base.repo ] && echo "yum source exist" && yum list && exit 4
            [ ! -f /etc/yum.repos.d/CentOS5-Base.repo ] && wget http://10.56.126.75/.help/CentOS5-Base.repo
            [ -f /etc/yum.repos.d/CentOS5-Base.repo ] && yum clean all &>/dev/null && echo "Clean Yum cache OK" || echo "Loading error." 
            yum makecache
            yum list
            rm -rf /so.txt
    
    else
            echo "error option"
            exit 4
    fi
    
    
  • 相关阅读:
    批处理显示系统信息与硬件信息
    批处理获取操作系统版本信息
    k2 4.6.9安装记录-够复杂了
    NAT路由器打洞原理
    function与感叹号
    leetcode 83. Remove Duplicates from Sorted List
    leetcode 53. Maximum Subarray
    leetcode 101. Symmetric Tree
    leetcode 191. Number of 1 Bits
    胜利的欲望不会给你胜利
  • 原文地址:https://www.cnblogs.com/ligao/p/5995505.html
Copyright © 2011-2022 走看看