任意版本openssh批量升级脚本

发表于 2019-05-28  14.16k 次阅读


此脚本在redhat以及centos的5、6、7、8版本测试、生产环境运行正常,在其他版本系统中如suse、ubuntu中脚本的无法安装一些软件包需要自己修改脚本,测试中运行正常 使用前请先在升级环境相同的测试系统中进行测试 理论上openssh和openssl各种版本都通用编译参数没有改动的话(现网中从7.4~8.0都升级过)

  • 脚本基本的原理:
    • 脚本共三个,一个检测和调用脚本(conbi.sh),一个openssh升级脚本(openssh_cp.sh),一个openssl升级脚本(openssl_cp.sh)
    • 当在需要升级的服务器执行conbi.sh时脚本默认会通过下载指定IP和端口的HTTP服务器中的opennssh_cp.sh以及openssl_cp.sh和安装中使用的源码包以及rpm包,检测pam-devel是否安装未安装则进行安装,检测是否开启telnet服务如果开启安装openssh后则不会关闭(针对业务需求不关闭开启的telnet,如果未开启则安装后也会关闭),然后执行openssl_cp.sh和openssh_cp.sh进行源码编译工作
    • telnet 的关闭时间为3600秒也就是60分钟
    • openssh安装完后10分钟后执行一遍命令行启动ssh(/usr/sbin/sshd)以防ssh启动失败的问题
    • openssh和openssl备份文件会在"/usr/lib/系统日期"或"/usr/lib64/系统日期"例如:/usr/lib64/2019-05-29 方便日后还原
    • 脚本中gcc和perl无法自动安装,其他依赖软件基本上都能够安装

如遇问题请查看输出日志,默认脚本中设置错误输出为/tmp/errorfile

使用前请先在升级环境相同的测试系统中进行测试

  • 需要修改项:
    • IpS=yourserverip:yourserverport
  •  可选更改项:
    • OPENSSHVERSION=8.0p1 #openssh升级的版本//后期有新版本可将源码包放至HTTP中更改次版本号
    • OPENSSLVERSION=1.0.2r #openssl升级的版本//后期有新版本可将源码包放至HTTP中更改次版本号
    • Server_DiR=/tools #服务器存放的目录
    • ScrIpt=$Server_DiR/scripts #服务器存放的脚本目录
    • SoftWare=$Server_DiR/software #服务器存放的软件目录

简易使用方法:

将上面的压缩包解压至HTTP服务的根目录

md5sum:02ebb83135837844e57aca76f7af9bc9 

更改脚本中的IpS为你服务器的ip以及HTTP服务的端口

需要升级的服务器执行

cd /tmp;curl -O http://yourip:port/tools/scripts/conbi.sh;sh conbi.sh

#[root@izhuhn root]# cat conbi.sh
#!/bin/bash
#2019/5/28
#scanz编写
#第16次修改

SSHVerSion=${1}
OPENSSHVERSION=8.0p1
[[ $SSHVerSion =~ ^[0-9]+.[0-9][a-Z][0-9]$ ]] || SSHVerSion=${OPENSSHVERSION}
#openssh 版本
#openssh version
#从命令行接收参数1ssh版本,默认为8.0p1

SSLVerSion=${2}
OPENSSLVERSION=1.0.2r
[[ $SSLVerSion =~ ^[0-9].[0-9].[0-9][a-Z]$ ]] ||  SSLVerSion=${OPENSSLVERSION}
#openssl版本
#Openssl version
#从命令行接收参数2为ssl版本,默认为1.0.2r

OUTok=/tmp/okfile
#输出的信息会保存到至此文件
#The output information is saved to this file.

OUTerror=/tmp/errorfile

#输出的报错信息会保存到至此文件
#The output error message is saved to this file.

TARTFILE=/tmp/159080113
if [[ ${TARTFILE} =~ ^/+$ ]]
then
        echo "目录不能为根"
        exit
fi
[[ ${TARTFILE} =~ .*/$ ]] && TARTFILE=`echo ${TARTFILE} | sed -n 's/\/$//p'`
#请不要将此变量改成已有目录,脚本结束后会删除此目录!!!!!!
#Do not change this variable to an existing directory and it will be deleted!!!!!!
#建议默认即可

IpS=yourip:yourport
#ping ${IpS} -c 1 &>/dev/null
#http服务器存放升级用到的包,可以更换成其他比如ftp但是需要更改脚本
#Http server stores the packages used for the upgrade,You can switch to another service but you need to change the script.

Server=http
#提供存放包的服务可使用匿名的ftp
#不建议更改其他,未经测试其他服务
Server_DiR=/tools
[[ ${Server_DiR} =~ .*/$ ]] && Server_DiR=`echo ${Server_DiR} | sed -n 's/\/$//p'`
#包存放的路径node:此路径是其他机器通过wget访问ip或者域名后面接的
#比如http://your_ip/tools/tar 此时下面需要用到的包都会从这个位置下载

ScrIpt=$Server_DiR/scripts
[[ ${ScrIpt} =~ .*/$ ]] && ScrIpt=`echo ${ScrIpt} | sed -n 's/\/$//p'`
#脚本存放服务器路径
SoftWare=$Server_DiR/software
[[ ${SoftWare} =~ .*/$ ]] && SoftWare=`echo ${SoftWare} | sed -n 's/\/$//p'`
#软件存放服务器路径
curl ${Server}://${IpS} &>/dev/null
if [ $? -ne 0 ]
then
      echo "${IpS}无法连通,请检查。"
      exit
fi

SSLPREHOME=/usr/local
SSHPREHOME=/usr/local
#openssl和openssh安装路径,请填写绝对路径
[[ ${SSHPREHOME} =~ .*/$ ]] && SSHPREHOME=`echo ${SSHPREHOME} | sed -n 's/\/$//p'`
[[ ${SSLPREHOME} =~ .*/$ ]] && SSLPREHOME=`echo ${SSLPREHOME} | sed -n 's/\/$//p'`
#

ZliBVerSion=1.2.11
ZLIB_TAR=zlib-${ZliBVerSion}.tar.gz
######Wget######
Wget5_RPM=wget-1.11.4-3.el5_8.2.x86_64.rpm
Wget6_RPM=wget-1.12-10.el6.x86_64.rpm
Wget7_RPM=wget-1.14-15.el7.x86_64.rpm
Wget8_RPM=wget-1.19.5-7.el8.x86_64.rpm
######Net-tools######
Net5_RPM=wget-1.11.4-3.el5_8.2.x86_64.rpm
Net6_RPM=wget-1.12-10.el6.x86_64.rpm
Net7_RPM=wget-1.14-15.el7.x86_64.rpm
Net8_RPM=wget-1.19.5-7.el8.x86_64.rpm
######PAM######
PAM5VerSion=0.99.6.2-12
PAM6VerSion=1.1.1-24
PAM7VerSion=1.1.8-22
PAM8VerSion=1.3.1-4
PAM5_RPM=pam-${PAM5VerSion}.el5.x86_64.rpm
PAM6_RPM=pam-${PAM6VerSion}.el6.x86_64.rpm
PAM7_RPM=pam-${PAM7VerSion}.el7.x86_64.rpm
PAM8_RPM=pam-${PAM8VerSion}.el8.x86_64.rpm
PAM5_DEVEL_RPM=pam-devel-${PAM5VerSion}.el5.x86_64.rpm
PAM6_DEVEL_RPM=pam-devel-${PAM6VerSion}.el6.x86_64.rpm
PAM7_DEVEL_RPM=pam-devel-${PAM7VerSion}.el7.x86_64.rpm
PAM8_DEVEL_RPM=pam-devel-${PAM8VerSion}.el8.x86_64.rpm
######TELNET######
TELNET5VerSion=0.17-41
TELNET6VerSion=0.17-48
TELNET7VerSion=0.17-64
TELNET8VerSion=0.17-73
TELNET5_SERVER_RPM=telnet-server-${TELNET5VerSion}.el5.x86_64.rpm
TELNET6_SERVER_RPM=telnet-server-${TELNET6VerSion}.el6.x86_64.rpm
TELNET7_SERVER_RPM=telnet-server-${TELNET7VerSion}.el7.x86_64.rpm
TELNET8_SERVER_RPM=telnet-server-${TELNET8VerSion}.el8.x86_64.rpm
######XINET######
XINET5VerSion=2.3.14-19
XINET6VerSion=2.3.14-40
XINET5_RPM=xinetd-${XINET5VerSion}.el5.x86_64.rpm
XINET6_RPM=xinetd-${XINET6VerSion}.el6.x86_64.rpm
######TAR######
OPENSSL_TAR=openssl-${SSLVerSion}.tar.gz
OPENSSH_TAR=openssh-${SSHVerSion}.tar.gz
######ScrIpt######
OH_SH=openssh_cp.sh
OL_SH=openssl_cp.sh
############
LANG=en
######bak######
[ -f ${OUTok} ] && mv ${OUTok}  ${OUTok}_$(date +%s)
[ -f ${OUTerror} ] && mv ${OUTerror}   ${OUTerror}_$(date +%s)
echo "--------------------$(date +%F)--------------------" > ${OUTok}
echo "--------------------$(date +%F)--------------------" > ${OUTerror}
######gcc_check######
rpm -qa | grep ^gcc-[0-9] >> ${OUTok} 2>> ${OUTerror}
if [ $? -ne 0 ]
then
      echo -e "\033[31m ##########检测到未安装gcc,请安装后再次重试执行##########  \033[0m"
      echo  "##########检测到未安装gcc,请安装后再次重试执行##########"  >> ${OUTerror}
      exit
fi
######perl_check######
rpm -qa | grep perl-[0-9] >> ${OUTok} 2>> ${OUTerror}
if [ $? -ne 0 ]
then
      echo -e "\033[31m ##########检测到未安装perl,请安装后再次重试执行##########  \033[0m"
      echo  "##########检测到未安装perl,请安装后再次重试执行##########" >> ${OUTerror}
      exit
fi
######Dir_check######
Dircheck(){
AA="${1}";eval BB="\$$AA"
if [[ ${BB} =~ ^/+$ ]]
then
        echo "${AA} 不能为根"
        exit
fi
unset AA
unset BB
}
Dircheck OUTok
Dircheck OUTerror
Dircheck TARTFILE
######Install_softwares_check######
#Software_check(){
#[ -f ]#暂定
#}
#Software_check 5
#Software_check 6
#Software_check 7
#Software_check 8
######download_tar_script_check######
#
#
######XinetdINSTALL######
XiNet_Telnet(){
rpm -qa | grep xinetd >> ${OUTok} 2>> ${OUTerror}
if [ $? -eq 0 ]
then
      rpm -qa | grep telnet-server >> ${OUTok} 2>> ${OUTerror}
	    if [ $? -ne 0 ]
	    then

		        AA="TELNET${1}_SERVER_RPM";eval AA="${TARTFILE}/\$$AA";rpm -ivh $(echo $AA) >> ${OUTok} 2>> ${OUTerror}
		        chkconfig telnet on
            /etc/init.d/xinetd status | grep  "stopped" >> ${OUTok} 2>> ${OUTerror}
			      if [ $? -eq 0 ]
			      then
                  /etc/init.d/xinetd start
                  sleep 3600 && chkconfig telnet off && /etc/init.d/xinetd stop &
            else
                  sleep 3600 && chkconfig telnet off &
            fi

      else
            netstat -anptu  | grep ":23 " |  grep LISTEN >> ${OUTok} 2>> ${OUTerror} && /etc/init.d/xinetd status | grep running >> ${OUTok} 2>> ${OUTerror}
            if [ $? -ne 0 ]
            then
                  chkconfig telnet on
                  /etc/init.d/xinetd start
                  netstat -anptu  | grep ":23 " |  grep LISTEN >> ${OUTok} 2>> ${OUTerror} && /etc/init.d/xinetd status | grep running >> ${OUTok} 2>> ${OUTerror}
                  if [ $? -eq 0 ]
                  then
                        /etc/init.d/xinetd status | grep  "stopped" >> ${OUTok} 2>> ${OUTerror}
                        if [ $? -eq 0 ]
                        then
                              sleep 3600 && chkconfig telnet off && /etc/init.d/xinetd stop &
                        else
                              sleep 3600 && chkconfig telnet off &
                        fi
                  fi
            fi

      fi
else
      AA="XINET${1}_RPM";eval AA="${TARTFILE}/\$$AA";rpm -ivh $(echo $AA) >> ${OUTok} 2>> ${OUTerror}
	    AA="TELNET${1}_SERVER_RPM";eval AA="${TARTFILE}/\$$AA"; rpm -ivh $(echo $AA) >> ${OUTok} 2>> ${OUTerror}
	    chkconfig telnet on
	    /etc/init.d/xinetd start
	    sleep 3600 && chkconfig telnet off && /etc/init.d/xinetd stop &
fi
}
TelNet(){
rpm -qa | grep telnet-server >> ${OUTok} 2>> ${OUTerror}
if [ $? -eq 0 ]
then
      netstat -anptu  | grep ":23 " |  grep LIST >> ${OUTok} 2>> ${OUTerror} && systemctl  status  telnet.socket | grep Active | grep active >> ${OUTok} 2>> ${OUTerror}
      if [ $? -ne 0 ]
      then
            systemctl start telnet.socket
            if [ $? -eq 0 ]
            then
                  sleep 3600 && systemctl stop telnet.socket &
            fi
      fi
else
      AA="TELNET${1}_SERVER_RPM";eval AA="${TARTFILE}/\$$AA"; rpm -ivh $(echo $AA) >> ${OUTok} 2>> ${OUTerror}
fi

}
######PAMUPDATE######
Pam_UPdate(){
rpm -qa | grep "^pam-devel.*.x86_64" >> ${OUTok} 2>> ${OUTerror}
if [ $? -ne  0 ]
then
      rpm -qa | grep -E "^pam-[0-9].*x86_64" >> ${OUTok} 2>> ${OUTerror}
  	  if [ $? -eq 0 ]
  	  then
            AA="PAM${1}VerSion";eval AA="\$$AA"
  		      rpm -qa | grep -E pam-${AA}.el${1}.x86_64 >> ${OUTok} 2>> ${OUTerror}
  		      if [ $? -eq 0 ]
  		      then
  			         AA="PAM${1}_DEVEL_RPM";eval AA="${TARTFILE}/\$$AA";rpm -ivh $(echo $AA) >> ${OUTok} 2>> ${OUTerror}
  		      else
  			         AA="PAM${1}_RPM";eval AA="${TARTFILE}/\$$AA";rpm -Uvh $(echo $AA) >> ${OUTok} 2>> ${OUTerror}
  			         if [ $? -eq 0 ]
  			         then
  				             AA="PAM${1}_RPM";eval AA="${TARTFILE}/\$$AA";rpm -ivh $(echo $AA) >> ${OUTok} 2>> ${OUTerror}
  			         else
  				             echo -e "\033[31m ##########PAM_update_error##########  \033[0m"
  				             echo "error: 系统自带pam版本与脚本指定pam-devel版本不符或者其他原因无法将当前pam升级至指定pam版本" >> ${OUTerror}
                       exit
  			         fi
  		      fi
  	  else
  		      AA="PAM${1}_RPM";eval AA="${TARTFILE}/\$$AA";rpm -ivh $(echo $AA) >> ${OUTok} 2>> ${OUTerror}
  		      AA="PAM${1}_DEVEL_RPM";eval AA="${TARTFILE}/\$$AA";rpm -ivh $(echo $AA) >> ${OUTok} 2>> ${OUTerror}
  	  fi
fi
}
######WgetSoftware######
Wget_all_other(){
for i in "${OPENSSL_TAR}" "${OPENSSH_TAR}" "${ZLIB_TAR}"
do
        if [ ! -f ${TARTFILE}/${i} ]
        then
              wget -c ${Server}://${IpS}${SoftWare}/${i}  >> ${OUTok} 2>> ${OUTerror}
              if [ $? -ne 0 ]
              then
                    echo "${i} 下载失败,请重试"
                    exit
              fi
        fi
done
wget -c ${Server}://${IpS}${ScrIpt}/${OH_SH}  >> ${OUTok} 2>> ${OUTerror}
if [ ! -f ${TARTFILE}/${OH_SH} ]
then
      echo "${OH_SH} 下载失败,请重试"
      exit
fi
wget -c ${Server}://${IpS}${ScrIpt}/${OL_SH}  >> ${OUTok} 2>> ${OUTerror}
if [ ! -f ${TARTFILE}/${OH_SH} ]
then
      echo "${OH_SH} 下载失败,请重试"
      exit
fi
}

Wget_all_redhat(){
PAM=PAM${1}_RPM;eval PAM="\$$PAM"
PAM_DEVEL=PAM${1}_DEVEL_RPM;eval PAM_DEVEL="\$$PAM_DEVEL"
TELNET=TELNET${1}_SERVER_RPM;eval TELNET="\$$TELNET"
for i in   "${OPENSSL_TAR}" "${OPENSSH_TAR}" "${ZLIB_TAR}" "${XINET5_RPM}" "${XINET6_RPM}" "$PAM" "$PAM_DEVEL" "$TELNET"
do
        if [ ! -f ${TARTFILE}/${i} ]
        then
              wget -c ${Server}://${IpS}${SoftWare}/${i}  >> ${OUTok} 2>> ${OUTerror}
              if [ $? -ne 0 ]
              then
                    echo "${i} 下载失败,请重试"
                    exit
              fi
        fi
done
wget -c ${Server}://${IpS}${ScrIpt}/${OH_SH}  >> ${OUTok} 2>> ${OUTerror}
if [ ! -f ${TARTFILE}/${OH_SH} ]
then
      echo "${OH_SH} 下载失败,请重试"
      exit
fi
wget -c ${Server}://${IpS}${ScrIpt}/${OL_SH}  >> ${OUTok} 2>> ${OUTerror}
if [ ! -f ${TARTFILE}/${OH_SH} ]
then
      echo "${OH_SH} 下载失败,请重试"
      exit
fi
}

mkdir -p ${TARTFILE}
cd ${TARTFILE}
#可定义针对不同版本的wget
######redhat5/centos5######
Version_5=`cat /etc/redhat-release  | grep "release 5."  >> ${OUTok} 2>> ${OUTerror}`
if [ $? -eq 0 ]
then
      rpm -qa | grep wget >> ${OUTok} 2>> ${OUTerror} ||  rpm -ivh ${Server}://${IpS}${SoftWare}/${Wget5_RPM}
      rpm -qa | grep net-tools >> ${OUTok} 2>> ${OUTerror} || rpm -ivh ${Server}://${IpS}${SoftWare}/${Net5_RPM}
      Wget_all_redhat 5
      XiNet_Telnet 5
      Pam_UPdate 5
fi
######redhat6/centos6######
Version_6=`cat /etc/redhat-release  | grep "release 6."  >> ${OUTok} 2>> ${OUTerror}`
if [ $? -eq 0 ]
then
      rpm -qa | grep wget >> ${OUTok} 2>> ${OUTerror} || rpm -ivh ${Server}://${IpS}${SoftWare}/${Wget6_RPM}
      rpm -qa | grep net-tools >> ${OUTok} 2>> ${OUTerror} || rpm -ivh ${Server}://${IpS}${SoftWare}/${Net6_RPM}
      Wget_all_redhat 6
      XiNet_Telnet 6
      Pam_UPdate 6
fi
######redhat7/centos7######
Version_7=`cat /etc/redhat-release  | grep "release 7."  >> ${OUTok} 2>> ${OUTerror}`
if [ $? -eq 0 ]
then
      rpm -qa | grep wget >> ${OUTok} 2>> ${OUTerror} || rpm -ivh ${Server}://${IpS}${SoftWare}/${Wget7_RPM}
      rpm -qa | grep net-tools >> ${OUTok} 2>> ${OUTerror} || rpm -ivh ${Server}://${IpS}${SoftWare}/${Net7_RPM}
      Wget_all_redhat 7
      Pam_UPdate 7
      TelNet 7
fi
######redhat8/centos8######
Version_8=`cat /etc/redhat-release  | grep "release 8."  >> ${OUTok} 2>> ${OUTerror}`
if [ $? -eq 0 ]
then
      rpm -qa | grep wget >> ${OUTok} 2>> ${OUTerror} || rpm -ivh ${Server}://${IpS}${SoftWare}/${Wget8_RPM}
      rpm -qa | grep net-tools >> ${OUTok} 2>> ${OUTerror} || rpm -ivh ${Server}://${IpS}${SoftWare}/${Net8_RPM}
      Wget_all_redhat 8
      Pam_UPdate 8
      TelNet 8
fi
######other######
if [ -f /etc/redhat-release ]
then
      echo "redhat" >> ${OUTok}
else
      Wget_all_other
      if [ $? -ne 0 ]
      then
            echo "Download error"
            exit
      fi
fi

######
tar -xvf ${ZLIB_TAR} > /dev/null 2>1

cd zlib-${ZliBVerSion}

echo "################Zlibconfigre################" >> ${OUTok}
echo "################Zlibconfigre################" >> ${OUTerror}

./configure >> ${OUTok} 2>> ${OUTerror}
if [ $? -ne 0 ]
then
      echo -e "\033[31m ##########Zlibconfig_error##########  \033[0m"
      exit
else
      echo -e "\033[32m####################Zlib_configure_ok####################\033[0m"

fi

echo "################Zlibmake################" >> ${OUTok}
echo "################Zlibmake################" >> ${OUTerror}

make  >> ${OUTok} 2>> ${OUTerror}
if [ $? -ne 0 ]
then
      echo -e "\033[31m ##########Zlibmake_error##########  \033[0m"
      exit
else
      echo -e "\033[32m####################Zlib_make_ok####################\033[0m"
fi


echo "################Zlibmakeinstall################" >> ${OUTok}
echo "################Zlibmakeinstall################" >> ${OUTerror}

make install  >> ${OUTok} 2>> ${OUTerror}
if [ $? -ne 0 ]
then
      echo -e "\033[31m ##########Zlibmakeinstall_error##########  \033[0m"
      exit
else
      echo -e "\033[32m####################Zlib_make_install_ok####################\033[0m"
fi

######
openssl version >/tmp/sslversiontemp
grep "${SSLVerSion}" /tmp/sslversiontemp  >> ${OUTok} 2>> ${OUTerror}
if [ $? -ne 0 ]
then
      sh ${TARTFILE}/${OL_SH} ${SSLVerSion} ${SSLPREHOME} ${OUTok} ${OUTerror} ${TARTFILE} &
      sleep 10
      OPENSSL_PID=$(cat /tmp/openssl_updateshell_pid)
      while :
      do
            ps aux | grep -v grep | grep ${OPENSSL_PID}  >> ${OUTok} 2>> ${OUTerror}
            if [ $? -eq 0 ]
            then
                  echo -e '请等待 -'"\b\b\b\b\b\b\b\b\c"
                  sleep 0.15
                  echo -e '请等待 \\'"\b\b\b\b\b\b\b\b\c"
                  sleep 0.15
                  echo -e '请等待 |'"\b\b\b\b\b\b\b\b\c"
                  sleep 0.15
                  echo -e '请等待 /'"\b\b\b\b\b\b\b\b\c"
            else
                  break
            fi
      done

      openssl version >/tmp/sslversiontemp
      grep "${SSLVerSion}" /tmp/sslversiontemp  >> ${OUTok} 2>> ${OUTerror}
      if [ $? -ne 0 ]
      then
            echo -e "\033[31m ##########OPENSSL_error##########  \033[0m"
            rm -f ${TARTFILE}/openssl-${SSLVerSion}
            exit
      else
            echo -e "\033[32m####################OPENSSL_INSTALL_OK####################\033[0m"
      fi

else
      echo -e "\033[32m####################OPENSSL_IS_ALREADY_THE_SPECIFIED_VERSION_####################\033[0m"
fi
######
df | grep /var$ >> ${OUTok} 2>> ${OUTerror}
if [ $? -eq  0 ]
then
      AA=`df | grep /var$ | awk '{ print $3 }'`
      if [ ${AA} -lt 10240 ]
      then
            echo -e "\033[31m ##########内存小于10M##########  \033[0m"
            echo "##########内存小于10M##########" >> ${OUTerror}
      fi
else
      AA=`df | grep /$ |  awk '{ print $3 }'`
      if [ ${AA} -lt 10240 ]
      then
            echo -e "\033[31m ##########内存小于10M##########  \033[0m"
            echo "##########内存小于10M##########" >> ${OUTerror}
      fi
fi
######
ssh -V 2>/tmp/sshversiontemp
grep "${SSHVerSion}" /tmp/sshversiontemp  >> ${OUTok} 2>> ${OUTerror}
if [ $? -ne 0 ]
then
      sh ${TARTFILE}/${OH_SH} ${SSLVerSion} ${SSHVerSion} ${SSLPREHOME} ${SSHPREHOME} ${OUTok} ${OUTerror} ${TARTFILE} &
      sleep 10
      OPENSSH_PID=$(cat /tmp/openssh_updateshell_pid)
      while :
      do
            ps aux | grep -v grep | grep ${OPENSSH_PID}  >> ${OUTok} 2>> ${OUTerror}
            if [ $? -eq 0 ]
            then

                  echo -e '请等待 -'"\b\b\b\b\b\b\b\b\c"
                  sleep 0.15
                  echo -e '请等待 \\'"\b\b\b\b\b\b\b\b\c"
                  sleep 0.15
                  echo -e '请等待 |'"\b\b\b\b\b\b\b\b\c"
                  sleep 0.15
                  echo -e '请等待 /'"\b\b\b\b\b\b\b\b\c"

            else
                  break
            fi
      done
      ssh -V 2>/tmp/sshversiontemp
      grep "${SSHVerSion}" /tmp/sshversiontemp  >> ${OUTok} 2>> ${OUTerror}
      if [ $? -ne 0 ]
      then
            echo -e "\033[31m ##########OPENSSH_ERROR##########  \033[0m"
            rm -f ${TARTFILE}/openssh-${SSLVerSion}
            exit
      else
            echo -e "\033[32m####################OPENSSH_INSTALL_OK####################\033[0m"
      fi
else
      echo -e "\033[32m####################OPENSSH_IS_ALREADY_THE_SPECIFIED_VERSION_####################\033[0m"
fi
##########################################
rm -f ${TARTFILE}/openssl-${SSLVerSion}.tar.gz
rm -f ${TARTFILE}/openssh-${SSHVerSion}.tar.gz
rm -rf ${TARTFILE}/openssl-${SSLVerSion}
rm -rf ${TARTFILE}/openssh-${SSLVerSion}
rm -f ${TARTFILE}/openssh_cp.sh
rm -f ${TARTFILE}/openssl_cp.sh
sleep 600 && rm -f /tmp/$0 &

全部脚本请下载压缩包,此处只展现其中一个脚本

本站文章基于国际协议BY-NA-SA 4.0协议共享;
如未特殊说明,本站文章皆为原创文章,请规范转载。

30

scanz个人博客