zoukankan      html  css  js  c++  java
  • 检查RPM包是否已经安装 枯木

    ###################RPM_CHECK1################# -->仅仅是检查单个rpm包是否安装,未安装的不能自动安装
    #!/bin/bash
    # check rpm is installed or not
    uname -r
    rpm --version
    
    echo
    P=${1?" must specify package name."}
    
    rpm -qa "$P" > t1
    my_size=$( wc -l < t1 )
    echo " Size of report file is $my_size lines"
    
    if [[ $( rpm -qa $P ) =~ ${P} ]]
    # if [[ $( rpm -qa $P ) == *${P}* ]]
    then
      echo " Package $P is installed."
    else
      echo " Package $P not found."
    fi
    
    exit 0
    ###################RPM_CHECK1#################


    ###################RPM_CHECK2#################  -->可以实现多种rpm包的检查,未安装的自动安装
    #!/bin/bash
    #filename: check_rpm
    uname -r
    rpm --version
    
    check_rpm()
    {
    	while (( $# > 0 ))
    	do
    		if ! rpm -q $1 &> /dev/null;then
    			yum install $1 -y &>/dev/null
    			if	[ $? == 0 ];then
    				echo "$1 install is success!"
    			else
    				echo "$1 is not in the systerm Packages!"
    			fi
    		fi
    	shift #执行一次shift则去掉第一个参数,始终只需判断$1即可  
    	done
    	exit 0
    }
    
    check_rpm $@
    ###################RPM_CHECK2################# 


    ###################RPM_CHECK3#################  -->结合以上两个脚本
    
    
    #!/bin/bash
    #filename: check_rpm
    uname -r
    rpm --version
    
    P=${1?" must specify package name."}  #加入这一行表示必须需要输入一个有效的软件包名
    
    check_rpm()
    {
    	while (( $# > 0 ))
    	do
    		if ! rpm -q $1 &> /dev/null;then
    			yum install $1 -y &>/dev/null
    			if	[ $? == 0 ];then
    				echo "$1 install is success!"
    			else
    				echo "$1 is not in the systerm Packages!"
    			fi
    		else 
    			echo "$1 is installed"
    		fi
    	shift #执行一次shift则去掉第一个参数,始终只需判断$1即可  
    	done
    	exit 0
    }
    ###################RPM_CHECK3################# 


  • 相关阅读:
    winform 计算器
    ajax无刷新上传图片
    Dapper的基本使用
    补充1
    Ajax2
    Ajax1
    jQuery2
    Select查询语句2
    jQuery1
    分页与组合查询
  • 原文地址:https://www.cnblogs.com/kumulinux/p/2808737.html
Copyright © 2011-2022 走看看