#!/bin/bash
#v1.0

CPE=3.4

CPE_ISO=$(cat /etc/cpeiso-release | awk '{print $3}')
echo "CPE-ISO : $CPE_ISO"
CPE_ISO=${CPE_ISO: 0: 3}

if [ `echo "$CPE_ISO >= $CPE"|bc` -eq 1 ];
then
    echo "No need to upgrade"
else
    echo "===================get httpd-tools httpd mod_ssl=============="
    wget http://test-update.vplink.link:80/httpd_mod_ssl/httpd-tools-2.4.6-97.el7.centos.x86_64.rpm
    wget http://test-update.vplink.link:80/httpd_mod_ssl/httpd-2.4.6-97.el7.centos.x86_64.rpm
    wget http://test-update.vplink.link:80/httpd_mod_ssl/mod_ssl-2.4.6-97.el7.centos.x86_64.rpm

    echo "========================== install ==========================="
    yum install -y httpd-tools-2.4.6-97.el7.centos.x86_64.rpm httpd-2.4.6-97.el7.centos.x86_64.rpm mod_ssl-2.4.6-97.el7.centos.x86_64.rpm
    
    echo "========================== check ============================="
    httpd_tools=$(rpm -q httpd-tools)
    httpd=$(rpm -q httpd)
    mod_ssl=$(rpm -q mod_ssl)
    if [ "$httpd_tools"x = "httpd-tools-2.4.6-97.el7.centos.x86_64"x ]&&[ "$httpd"x = "httpd-2.4.6-97.el7.centos.x86_64"x ]&&[ "$mod_ssl"x = "mod_ssl-2.4.6-97.el7.centos.x86_64"x ]
    then
        echo "update successed"
    else
        echo "upgrade unsuccessful"
    fi
fi
