本地yum服务器脚本

#!/bin/bash
# wrote by dywer
cd_path='/win/e/ISO/linux/rhel5u4.iso'
repo_dir='/win/cd'
mkdir -p $repo_dir
grep -q iso9660 /etc/fstab || \
echo "
$cd_path  file://$repo_dir iso9660 noatuo,loop,ro 0 0
" >> /etc/fstab
#rpm -ivh /media/yumCD/Server/createrepo.rpm
mkdir -p /etc/yum.repos.d/bak
mv /etc/yum.repos.d/* /etc/yum.repos.d/bak
#rpm --import /media/yumCD/RPM-GPG-KEY-redhat-release
[ -f /etc/yum.repos.d/local.repo ]  || \
echo "
[Cluster]
name=Red Hat Enterprise Linux \$releasever - \$basearch - Cluster
baseurl=file://${repo_dir}/Cluster
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[ClusterStorage]
name=Red Hat Enterprise Linux \$releasever - \$basearch - ClusterStorage
baseurl=file://${repo_dir}/ClusterStorage
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[Server]
name=Red Hat Enterprise Linux \$releasever - \$basearch - Server
baseurl=file://${repo_dir}/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[VT]
name=Red Hat Enterprise Linux \$releasever - \$basearch - VT
baseurl=file://${repo_dir}/VT
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
" > /etc/yum.repos.d/local.repo
mount $repo_dir
yum clean all

你可能感兴趣的:(职场,yum,休闲)