CentOS builds local Yum source shell script

Source: Internet
Author: User

How to use:

1. Download the deltarpm-version.el6.x86_64.rpm python-deltarpm-version.el6.x86_64.rpm createrepo-version.noarch.rpm for the system version , put it in the sibling directory corresponding to the script.
2. Take the rpm that needs to be made into the source (it is recommended that the corresponding system version of the 32-bit and 64-bit ISO rpm are taken out) into a directory, such as "/tmp/packages", run the script directly.

The code below, not much to say @. [Email protected]

#!/bin/SH#请下载系统版本对应的"deltarpm-version.el6.x86_64.rpm python-deltarpm-version.el6.x86_64.rpm#createrepo-version.noarch.rpm", put it in the corresponding sibling directory of the scriptSet-efunctionCheckroot () {#checkifcurrect use is root usercur_user=`WhoAmI`if[$CUR _user! ='Root' ] Then      Echo 'The operation would modify system files,you should be root!'Exit1fi}functionMkDir () {if[!-D $1 ] Then    mkdir$1>/dev/NULLfi}functionRollBack () {Orig_dir=`pwd' CD/etc/Yum. repos.d >/dev/NULLMkDir/ect/Yum. repos.d/CONFIGYUM_RBMV*.repo configyum_rb/>/dev/NULLMVBackup/*. Repo. >/dev/nullrm-fr backup/configyum_rb/>/dev/nullyum Clean all >/dev/nullyum makecache >/dev/nullyum Repol Ist all}function Create () {echo ' Begin to create local Yum source ... ' orig_dir= ' pwd ' #backup currect configif [!-d "/E    TC/YUM.REPOS.D "] then echo '/ETC/YUM.REPOS.D isn't existed, please check your system! ' Exit 1 ficd/etc/yum.repos.d >/DEV/NULLMKDIR/ETC/YUM.REPOS.D/BACKUPMV/*.repo backup/#create local.repocat >&gt ; Local.repo << eof[localrepo]name=localrepobaseurl=file://$1gpgcheck=0enabled=1eofretrpm= ' Rpm-qa | grep deltarpm ' If [-Z ' $retrpm ']then rpm-ivh $ORIG _dir/deltarpm-.*.rpm >/dev/null rpm-ivh $ORIG _dir/python-deltar pm-.*.rpm >/dev/nullfi#check If Createrepo if Existedwhich createrepo >/dev/nullif [$?-eq 1]then rpm-ivh $ORI    g_dir/createrepo.*.noarch.rpm >/dev/null If [$-ne 0] then echo ' Install Createrepo failed! ' Exit 1 Fificreaterepo $ >/dev/nullif [$?-ne 0]then Echo ' CreaTe repo failed! ' Exit 1fiyum Clean all >/dev/nullyum makecache >/dev/nullyum repolist all}function Help () {Cat <<eofthere is 2 ways to call this script, for Example:1. To create a local Yum Source:./configyum.sh/tmp/packages2.   To rollback previous operation:./configyum.sh beof}function Main () {if [$#-ne 1]then helpelif [-D $]then checkroot     Create $*elif [$ = ' B ']then checkroot rolllbackelse helpfi}main $*

CentOS builds local Yum source shell script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.