测试环境:CentOS 6.4 裸机
注意事项:
1. 关闭SELinux
2. 关闭iptables
3. 根据DVD1,DVD2所挂载的目录修改脚本
4. 当系统有两个虚拟光驱时,注意查看/dev/cdrom,若与脚本不匹配,请作相应的修改
5. 系统需联网
6. 脚本不完善,没有加入错误中断机制
7. 脚本运行情况还需优化
脚本如下:
#!/bin/bash # vflong 2014-4-3 # CentOS 6.4 #NOTE: # DVD1 in cdrom1, DVD2 in cdrom2 #WARNING # Please close you iptables and SELinux PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin export PATH IPADDR=$(ifconfig eth0 | grep 'inet addr' | cut -d ':' -f2 | cut -d ' ' -f1) BASEDIR=/etc/yum.repos.d FTPDIR=/etc/vsftpd mkdir -p /mnt/dvd1 mkdir -p /mnt/dvd2 mkdir -p /yum umount /mnt/dvd1 2> /dev/null umount /mnt/dvd2 2> /dev/null mount /dev/cdrom1 /mnt/dvd1 2> /dev/null mount /dev/cdrom2 /mnt/dvd2 2> /dev/null rm -rf $BASEDIR/CentOS-* #set local yum echo "[Packages] name=Packages baseurl=file:///mnt/dvd1 gpgcheck=0 enabled=1" > $BASEDIR/yum.repo yum clean all && yum repolist all #install vsftpd yum install -y vim man ftp vsftpd createrepo ntpdate #copy Packages cp -urf /mnt/dvd1/* /yum/ cp -urf /mnt/dvd2/Packages/* /yum/Packages/ createrepo -v /yum/Packages/ #set ftp yum echo "[Packages] name=Packages baseurl=ftp://$IPADDR/Packages gpgcheck=0 enabled=1" > $BASEDIR/yum.repo #set autorun chkconfig vsftpd on #modify conf echo "anon_upload_enable=YES anon_root=/yum" >> $FTPDIR/vsftpd.conf /etc/init.d/vsftpd restart yum clean all && yum repolist all
转载于:https://blog.51cto.com/vflong/1390117