NOVOTS KMS 词汇表 Glossary    联系我们 Contact Us
查询 Search  
   
按类别浏览 Browse by Category
NOVOTS KMS .: 操作系统 .: Unix/Linux .: shell脚本实现自动配置yum

shell脚本实现自动配置yum

 大家都知道在RedHat中yum的好处,可以解决依赖关系,轻松的安装和卸载软件包。下面的脚本是我当初在初学shell脚本编程时写的第一个可以完成实际功能的简单脚本,和大家分享一下。



#!/bin/bash

#This program is used for helping you configure yum for your system.
#Written by Levin Wong<findingcc@126.com>.
#Written on xxxx.

trap 'echo;exit 0;'    2    15

echo "This program will configure yum automatically. "

read -p "Please input the CD path:"    path

until [ -e "$path"/Server ]
do
    read    -p "Error CD path!Please retry:" path
done

{
rpm -ivh $path/Server/createrepo-0.4.11-3.el5.noarch.rpm

createrepo -g    $path/Server/repodata/comps-rhel5-server-core.xml $path/Server

createrepo -g $path/VT/repodata/comps-rhel5-vt.xml $path/VT

createrepo -g $path/Cluster/repodata/comps-rhel5-cluster.xml $path/Cluster

createrepo -g $path/ClusterStorage/repodata/comps-rhel5-cluster-st.xml $path/ClusterStorage
}&>/dev/null

############################

cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/server.repo

cat > /etc/yum.repos.d/server.repo <<EOF
[rhel-server]
name=rhel-server
baseurl=file://$path/Server/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[rhel-cluster]
name=rhel-cluster
baseurl=file://$path/Cluster/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[rhel-clusterstorage]
name=rhelclusterstorage
baseurl=file://$path/ClusterStorage/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[rhel-vt]
name=rhelvt
baseurl=file://$path/VT/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
EOF


{
yum clean all
yum list
}&>/dev/null

if [ "$?" -eq "0" ]
then
  echo "Success!^_^ "
else
  echo "Failed!"
  exit 1
fi

exit 0


这篇文章对你多有用?

相关文章

article Windows 7 Shell 命令大名单
对于熟悉了命令行的人而言,用键盘调用程序比鼠标更...

(No rating)  6-15-2011    Views: 738   
article 使用Bash Shell对目录中的文件实现递归式拷贝
 

(No rating)  2-21-2019    Views: 109   
article 使用Bash Shell获取文件名和目录名的简单方法-李慧君
获取文件名 假设给定的路径名为: ...

(No rating)  10-25-2018    Views: 155   

用户评语

添加评语
当前还没有评语.


.: .: .: .: .:
[ 登陆 ]
北京护航科技有限公司 2006

Novots Technologies Limited