日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
CentOS建立本地yum源shell腳本

使用方法:
1.下載系統(tǒng)版本對應(yīng)的"deltarpm-version.el6.x86_64.rpm python-deltarpm-version.el6.x86_64.rpm createrepo-version.noarch.rpm",放到腳本對應(yīng)的同級目錄。
2.把需要做成源的rpm(建議把對應(yīng)系統(tǒng)版本的32位和64位iso中的rpm都拿出來)放到一個(gè)目錄下,如放到"/tmp/packages",直接運(yùn)行腳本即可。

靖宇網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)公司!從網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、響應(yīng)式網(wǎng)站等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營維護(hù)。成都創(chuàng)新互聯(lián)公司自2013年創(chuàng)立以來到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(lián)公司。

代碼如下,就不多說了

#!/bin/sh

#請下載系統(tǒng)版本對應(yīng)的"deltarpm-version.el6.x86_64.rpm python-deltarpm-version.el6.x86_64.rpm
#createrepo-version.noarch.rpm",放到腳本對應(yīng)的同級目錄
 
set -e

function CheckRoot()
{
#check if currect use is root user
CUR_USER=`whoami`
if [ $CUR_USER != 'root' ]
then
      echo 'The operation will modify system files,you should be  root!'
  exit 1
fi
}

function MkDir()
{
if [ ! -d $1 ]
then
  mkdir $1 > /dev/null
fi
}

function RollBack()
{
ORIG_DIR=`pwd`
cd /etc/yum.repos.d > /dev/null
MkDir /ect/yum.repos.d/configYum_rb
mv *.repo configYum_rb/ > /dev/null
mv backup/*.repo . > /dev/null
rm -fr backup/ configYum_rb/ > /dev/null
yum clean all > /dev/null
yum makecache > /dev/null
yum repolist all
}

function Create()
{
echo 'Begin to create local yum source ... ...'
ORIG_DIR=`pwd`

#backup currect config
if [ ! -d "/etc/yum.repos.d" ]
  then
    echo '/etc/yum.repos.d is not existed , please check your system!'
    exit 1
  fi

cd /etc/yum.repos.d > /dev/null
MkDir /etc/yum.repos.d/backup
mv ./*.repo backup/

#create local.repo
cat >> local.repo << EOF
[localrepo]
name=localrepo
baseurl=file://$1
gpgcheck=0
enabled=1
EOF

retrpm=`rpm -qa | grep deltarpm`
if [ -z "$retrpm" ]
then
  rpm -ivh $ORIG_DIR/deltarpm-.*.rpm > /dev/null
  rpm -ivh $ORIG_DIR/python-deltarpm-.*.rpm > /dev/null
fi

#check if createrepo if existed
which createrepo > /dev/null

if [ $? -eq 1 ]
then
  rpm -ivh $ORIG_DIR/createrepo.*.noarch.rpm > /dev/null
  if [ $? -ne 0 ]
  then
    echo 'Install createrepo failed !'
    exit 1
  fi
fi

createrepo $1 > /dev/null

if [ $? -ne 0]
then
  echo 'create repo failed !'
  exit 1
fi

yum clean all > /dev/null
yum makecache > /dev/null
yum repolist all
}

function Help()
{
cat <There are 2 ways to call this script, for example:
1. To create a local Yum source: ./configYum.sh /tmp/packages
2. To rollback previous operation: ./configYum.sh b
EOF
}

function Main()
{
if [ $# -ne 1 ]
then
  Help
elif [ -d $1 ]
then
  CheckRoot
  Create $*
elif [ $1 = 'b' ]
then
  CheckRoot
  RolllBack
else
  Help
fi
}

Main $* 


網(wǎng)站名稱:CentOS建立本地yum源shell腳本
文章路徑:http://m.5511xx.com/article/coojhdp.html