分类
未分类

shell判断python和openssl版实现自动根据环境部署应用

#!/bin/sh
check()
{
#e.g. python version 2.7(P1.P2)
#e.g. openssl version 1.0.2(O1.O2.O3)
    P1=2
    P2=7
    O1=1

    UP1=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'`
    UP2=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $2}'`
    UO1=`openssl version|awk '{print $2}'|awk -F '.' '{print $1}'`

   echo $UP1.$UP2
   echo $UO1


    if [ $UP1 -gt $P1 ]&&[ $UO -eq $O ];then
        echo 'Your python version is 3+!, Openssl version is 1+'
    elif [ $UP1 -eq $P1 ]&&[ $UO -eq $O ];then
        if [ $UP2 -ge $P2 ]&&[ $UO -eq $O ];then
            echo 'Your python version is 2.7+!, Openssl version is 1+'
        elif [ $UP2 -lt $P2 ]&&[ $UO -eq $O ];then
            echo 'Your python version is 2.7-!, Openssl version is 1+'
        elif [ $UP2 -lt $P2 ]&&[ $UO -lt $O ];then
            echo 'Your python version is 2.7-!, Openssl version is 1-'
        fi
    else
           echo 'no python , Openssl version is 1-'
    fi
}
check