yum源的创建脚本
#!/bin/bash# Title: yumcreate.sh# Author: cliang(gnome_dj@163.com)# Description: This is a script# Date:20140317 16:54# Version: 0.1#mount the Linux disk dvd1 & dvd2.#Web directory for storage rpm file. DST="/var/www/html/yum/CentOS-6.3-x86_64"SUR="/tmp/$(date +%N%s)"#The repo file name.REPO="CentOS-6.3-x86_64.repo"#Iso file location.DVDPATH1="/home/share/CentOS-6.3-x86_64-bin-DVD1.iso"DVDPATH2="/home/share/CentOS-6.3-x86_64-bin-DVD2.iso"SIP=$(ifconfig eth0|grep "inet addr"|awk -F":" '{print $2}'|awk '{print $1}'){if [ ! -d $DST ];then mkdir $DST -p chmod +w $DST -Rfimkdir if [ ! -d $SUR ];then mkdir $SUR -pfi} 2> /dev/nullmount -o loop $DVDPATH1 $SUR#cp -rf $SUR/ $DST/rsync -a $SUR/ $DST/umount $SURmount -o loop $DVDPATH2 $SUR#cp -rf $SUR/ $DST/rsync -a $SUR/ $DSTumount $SURrm -rf $SUR#Make yum group.cd $DSTcreaterepo -g $(find $DST |grep comps.xml$) . >/dev/nullecho "[CentOS6.4]" > $DST/$REPOecho "name=CentOS-\$releasever - Base" >> $DST/$REPOecho "baseurl=http://"$SIP"/yum/CentOS-6.3-x86_64" >> $DST/$REPOecho "gpgcheck=0" >> $DST/$REPOecho "enabled=1" >> $DST/$REPO#Change purview only read.chmod -w -R $DST#HTTP configuration.echo 'Alias "/yum" "/var/www/html/yum/"' >>/etc/httpd/conf/httpd.confecho '' >>/etc/httpd/conf/httpd.confecho ' Order allow,deny' >>/etc/httpd/conf/httpd.confecho ' Allow from all' >>/etc/httpd/conf/httpd.confecho '' >>/etc/httpd/conf/httpd.conf#Reload apache service.service httpd restart 1>/dev/null 2>/dev/null
客户端使用的时候可以执行
#!/bin/sh#Client repos configure{if [ ! -d /etc/yum.repos.d/bak ];then mkdir /etc/yum.repos.d/bakfifor i in $(ls /etc/yum.repos.d/|grep -v bak);do mv $i /etc/yum.repos.d/bakdone} >/dev/nullwget http://192.168.x.x/yum/CentOS-6.3-x86_64/CentOS-6.3-x86_64.repo -O /etc/yum.repos.dyum clean allyun listyun grouplistyum search "xxx"