rhel镜像制作本地yum源脚本

#!/bin/bash


mount(){

        mkdir /mnt/cdrom

        mkdir /var/yum

        mount /dev/cdrom /mnt/cdrom

        cp -r /mnt/cdrom/* /var/yum/

        echo "Copy files have done"

}


yum(){

cat > /etc/yum.repos.d/rc.repo << EOF

[Server]

name=Server

baseurl=file:///var/yum/Server

enabled=1

gpgcheck=0

[VT]

name=VT

baseurl=file:///var/yum/VT

enabled=1

gpgcheck=0

[Cluster]

name=Cluster

baseurl=file:///var/yum/Cluster

enabled=1

gpgcheck=0

[ClusterStorage]

name=ClusterStorage

baseurl=file:///var/yum/ClusterStorage

enabled=1

gpgcheck=0

EOF

echo "Create rc.repo have done"

}


repo=`which createrepo`

createrepo(){

        rpm -ivh /var/yum/Server/createrepo-* && echo "install createrepo finished" || exit 1

        $repo -g /mnt/cdrom/Server/repodata/comps-rhel5-server-core.xml /var/yum/Server/

        echo="Server is finish"

        $repo -g /mnt/cdrom/VT/repodata/comps-rhel5-vt.xml /var/yum/VT/

        echo="VT is finish"

        $repo -g /mnt/cdrom/Cluster/repodata/comps-rhel5-cluster.xml /var/yum/Cluster/

        echo="Cluster is finish"

        $repo -g /mnt/cdrom/ClusterStorage/repodata/comps-rhel5-cluster-st.xml /var/yum/ClusterStorage/

        echo="ClusterStorage is finish"

}


mount

yum

createrepo

yum clean all && yum makecache

echo "There is OK"

你可能感兴趣的:(yum,createrepo)