每日一shell(十)yum安装包for循环检查安装

前端之家收集整理的这篇文章主要介绍了每日一shell(十)yum安装包for循环检查安装前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

有时候安装yum包,发现有的已经安装过了但是如果执行安装,yum需要检查源,输出一堆的信息,看起来很烦,于是就想到了先检查后安装,如果本地已经安装,不执行安装,如果没有安装就进行安装。

去重后需要安装的yum安装包如下:

autoconf bison bison-devel bzip2 bzip2-devel ca-certificates cairo-devel c-ares c-ares-devel cmake crontabs curl curl-devel diffutils
e2fsprogs e2fsprogs-devel expat-devel file flex freetype freetype-devel gcc gcc-c++ gcc-g77 gd gd-devel gettext gettext-devel git-core glib2 gl
ib2-devel glibc.i686 gmp-devel icu kernel-devel krb5 krb5-devel libaio-devel libcap libc-client-devel libcurl libcurl-devel libevent libevent-d
evel libicu-devel libidn libidn-devel libjpeg libjpeg-devel libpng libpng10 libpng10-devel libpng-devel libstdc++.so.6 libtool libtool-libs lib
webp libwebp-devel libxml2 libxml2-dev libxml2-devel libXpm-devel libxslt libxslt* libxslt-devel lsof make ncurses ncurses-devel net-tools open
ssl openssl-devel patch pcre pcre-devel perl perl-Data-Dumper perl-devel psmisc pspell-devel python-devel python-imaging readline-devel tar unz
ip vim-minimal vixie-cron wget zip zlib zlib-devel

shell源码

cat yumci.sh
#!/bin/bash
#writen by Aiker

myum() {
if ! rpm -qa|grep -q "^$1"
then
    yum install -y $1
    check_ok
else
    echo $1 already installed.
fi
}

check_ok() {
if [ $? != 0 ]
then
    echo "Error,Check the error log."
fi
}

for p in autoconf bison bison-devel bzip2 bzip2-devel ca-certificates cairo-devel c-ares c-ares-devel cmake crontabs curl curl-devel diffutils
e2fsprogs e2fsprogs-devel expat-devel file flex freetype freetype-devel gcc gcc-c++ gcc-g77 gd gd-devel gettext gettext-devel git-core glib2 gl
ib2-devel glibc.i686 gmp-devel icu kernel-devel krb5 krb5-devel libaio-devel libcap libc-client-devel libcurl libcurl-devel libevent libevent-d
evel libicu-devel libidn libidn-devel libjpeg libjpeg-devel libpng libpng10 libpng10-devel libpng-devel libstdc++.so.6 libtool libtool-libs lib
webp libwebp-devel libxml2 libxml2-dev libxml2-devel libXpm-devel libxslt libxslt* libxslt-devel lsof make ncurses ncurses-devel net-tools open
ssl openssl-devel patch pcre pcre-devel perl perl-Data-Dumper perl-devel psmisc pspell-devel python-devel python-imaging readline-devel tar unz
ip vim-minimal vixie-cron wget zip zlib zlib-devel;do myum $p;done

输出实例如下:

```[root@aaa ~]# sh ci.sh
autoconf already installed.
bison already installed.
bison-devel already installed.
bzip2 already installed.
bzip2-devel already installed.
ca-certificates already installed.
cairo-devel already installed.
c-ares already installed.
c-ares-devel already installed.
cmake already installed.
crontabs already installed.
curl already installed.
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: mirrors.aliyun.com
  • epel: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    Package libcurl-devel-7.29.0-42.el7_4.1.x86_64 already installed and latest version
    Nothing to do
    diffutils already installed.
    e2fsprogs already installed.
    e2fsprogs-devel already installed.
    expat-devel already installed.
    file already installed.
    flex already installed.
    freetype already installed.
    freetype-devel already installed.
    gcc already installed.
    gcc-c++ already installed.
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
  • base: mirrors.aliyun.com
  • epel: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    No package gcc-g77 available.
    Error: Nothing to do
    Error,Check the error log.
    gd already installed.
    gd-devel already installed.
    gettext already installed.
    gettext-devel already installed.
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
  • base: mirrors.aliyun.com
  • epel: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    Package git-1.8.3.1-12.el7_4.x86_64 already installed and latest version
    Nothing to do
    glib2 already installed.
    glib2-devel already installed.
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
  • base: mirrors.aliyun.com
  • epel: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    Package glibc-2.17-196.el7_4.2.i686 already installed and latest version
    Nothing to do
    gmp-devel already installed.
    icu already installed.
    kernel-devel already installed.
    krb5 already installed.
    krb5-devel already installed.
    libaio-devel already installed.
    libcap already installed.
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
  • base: mirrors.aliyun.com
  • epel: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    Package uw-imap-devel-2007f-16.el7.x86_64 already installed and latest version
    Nothing to do
    libcurl already installed.
    libcurl-devel already installed.
    libevent already installed.
    libevent-devel already installed.
    libicu-devel already installed.
    libidn already installed.
    libidn-devel already installed.
    libjpeg already installed.
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
  • base: mirrors.aliyun.com
  • epel: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    Package libjpeg-turbo-devel-1.2.90-5.el7.x86_64 already installed and latest version
    Nothing to do
    libpng already installed.
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
  • base: mirrors.aliyun.com
  • epel: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    No package libpng10 available.
    Error: Nothing to do
    Error,Check the error log.
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
  • base: mirrors.aliyun.com
  • epel: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    No package libpng10-devel available.
    Error: Nothing to do
    Error,Check the error log.
    libpng-devel already installed.
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
  • base: mirrors.aliyun.com
  • epel: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    Package libstdc++-4.8.5-16.el7_4.2.i686 already installed and latest version
    Nothing to do
    libtool already installed.
    aded plugins: fastestmirror
    ▽oading mirror speeds from cached hostfile
  • base: mirrors.aliyun.com
  • epel: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    Package libtool-ltdl-2.4.2-22.el7_3.x86_64 already installed and latest version
    Nothing to do
    libwebp already installed.
    libwebp-devel already installed.
    libxml2 already installed.
    libxml2-dev already installed.
    libxml2-devel already installed.
    libXpm-devel already installed.
    libxslt already installed.
    libxslt* already installed.
    libxslt-devel already installed.
    lsof already installed.
    make already installed.
    ncurses already installed.
    ncurses-devel already installed.
    net-tools already installed.
    openssl already installed.
    openssl-devel already installed.
    patch already installed.
    pcre already installed.
    pcre-devel already installed.
    perl already installed.
    perl-Data-Dumper already installed.
    perl-devel already installed.
    psmisc already installed.
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
  • base: mirrors.aliyun.com
  • epel: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    No package pspell-devel available.
    Error: Nothing to do
    Error,Check the error log.
    python-devel already installed.
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
  • base: mirrors.aliyun.com
  • epel: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    Package python-pillow-2.0.0-19.gitd1c6db8.el7.x86_64 already installed and latest version
    Nothing to do
    readline-devel already installed.
    tar already installed.
    unzip already installed.
    vim-minimal already installed.
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
  • base: mirrors.aliyun.com
  • epel: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.comNo package vixie-cron available.Error: Nothing to doError,Check the error log.wget already installed.zip already installed.zlib already installed.zlib-devel already installed.
原文链接:https://www.f2er.com/bash/388506.html

猜你在找的Bash相关文章