#!/bin/bash
folder="/eisc/yum" # 定義下載下傳目錄
mkdir -p $folder # 建立下載下傳目錄
wgetfile=(
https://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpm https://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm https://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.i686.rpm https://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm https://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm https://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm https://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm https://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm)
iffile="$folder/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm"
# 定義已經存在的檔案
if [ ! -e $iffile ] # 判斷檔案 ! 不存在,then 開始
then
for ((i=0;i<${#wgetfile[*]};i++))
# i初始為0 數組角标從0開始
# i 範圍為 0 到 小于數組個數值,這個區間自增加
# 數組 [*] 符号*指定所有,可以改為0從第一個角标,1表示第二個
# 不加#号表示展示數組元素
do
wget -P $folder ${wgetfile[$i]}
# wget -P 檔案夾 被下載下傳的檔案
done
else
echo "安裝檔案已經下載下傳!"
fi
#------- 安裝 -------#
rpmfile=(
`ls $folder`
for((i=0;i<${#rpmfile[*]};i++ ))
do
rpm -ivh --force --nodeps $folder/${rpmfile[$i]}
done