腳本全自動創建本地yum源

#! /bin/bash
# make_local_yum_source.sh :

mkdir /var/yum /media/cdrom

mount /dev/cdrom /media/cdrom
echo "Time to rsync the cdrom to /var/yum"
rsync -r /media/cdrom/* /var/yum

umount /dev/cdrom
echo "Time to create metadata"
rpm -q createrepo

if [ $? -eq 0 ];then
createrepo -g /var/yum/Server/repodata/comps-rhel5-server-core.xml /var/yum/Server
createrepo -g /var/yum/VT/repodata/comps-rhel5-vt.xml /var/yum/VT
createrepo -g /var/yum/Cluster/repodata/comps-rhel5-cluster.xml /var/yum/Cluster
createrepo -g /var/yum/ClusterStorage/repodata/comps-rhel5-cluster-st.xml /var/yum/ClusterStorage
else
rpm -ivh /var/yum/Server/createrepo-0.4.11-3.el5.noarch.rpm
createrepo -g /var/yum/Server/repodata/comps-rhel5-server-core.xml /var/yum/Server
createrepo -g /var/yum/VT/repodata/comps-rhel5-vt.xml /var/yum/VT
createrepo -g /var/yum/Cluster/repodata/comps-rhel5-cluster.xml /var/yum/Cluster
createrepo -g /var/yum/ClusterStorage/repodata/comps-rhel5-cluster-st.xml /var/yum/ClusterStorage
fi
"Time to create .repo file"
touch /etc/yum.repos.d/local.repo

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

[base]
name=base
baseurl=file:///var/yum/Server
gpgcheck=0

[VT]
name=VT
baseurl=file:///var/yum/VT
gpgcheck=0


[Cluster]
name=Cluster
baseurl=file:///var/yum/Cluster
gpgcheck=0


[ClusterStorage]
name=CS
baseurl=file:///var/yum/ClusterStorage
gpgcheck=0

EOF
"Time to install httpd for test"
yum install httpd

if [ $? -eq 0 ];then
echo -e "\033[31mYou done a good job....\033[m"
else
echo "you fool..."
fi

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章