#!/bin/bash
# 安装函数
install(){
   for soft in $*
   do
        echo "$soft"安装中...
        yum -y install $soft &>/dev/null
        if [ $? -ne 0 ];then
#                echo "$soft"安装失败
                echo "$soft"安装失败 >> /opt/log.txt
#               return 48
        else
                systemctl restart $soft &> /dev/null
                if [ $? -ne 0 ];then
                        systemctl restart "$soft"d &> /dev/null
                        [ $? -ne 0 ] && echo "$soft"启动失败 >> /opt/log.txt
                        systemctl enable "$soft"d &> /dev/null
                else
                        systemctl enable $soft &> /dev/null
#                       return 0
                fi

                 echo "$soft"安装成功

                 echo "$soft"安装成功 >> /opt/log.txt
        fi
   done
}

yum list &> /dev/null
if [ $? -ne 0 ];then
        echo yum源不可用 > /opt/log.txt
else
        install $*
fi

相关文章:

  • 2022-12-23
  • 2021-11-15
  • 2021-12-31
  • 2022-12-23
  • 2021-07-18
  • 2021-04-11
  • 2022-12-23
  • 2022-02-07
猜你喜欢
  • 2022-01-23
  • 2021-08-27
  • 2022-01-24
  • 2021-11-07
  • 2022-12-23
  • 2021-09-06
  • 2021-08-01
相关资源
相似解决方案