CentOS6.x 制作ubuntu12.04源

使用ubuntu已经习惯了用apt-get 来安装软件了,使用网络源有时网速太慢,让人很头疼,加之网络源常有更新,可能会导致安装软件的版本不一致,导致无法在现有稳定环境中运行,之前已经做过在ubuntu上制作本地源,本问主要介绍在centos下制作ubuntu12.04本地源,主要参考一个老外写的脚步,执行这个脚本,剩下的就是等待了,按照公司的网络来说估计要下一个星期左右。下面是脚本内容,其中包括了32位和64位的,其实只需下载64位的就可以了,服务上安装的大多数都是64位操作系统,不过还是一起下载了吧,以备不时之需。

这个脚本运行需要这个脚本运行环境,需要debmirror环境,脚本内容:

其中SOURCE_SRV=debian.ustc.edu.cn,这个可以根据自己需要进行修改,我这里下载的是科大的源,因为离的比较近,相对来说应该会快些!

 

###########################################################################
##                                                                       ##
##                         Ubuntu Mirror Script                          ##
##                                                                       ##
## Creation:    06.07.2008                                               ##
## Last Update: 02.06.2012                                               ##
##                                                                       ##
## Copyright (c) 2008-2012 by Georg Kainzbauer <georgkainzbauer@gmx.net> ##
##                                                                       ##
## This program is free software; you can redistribute it and/or modify  ##
## it under the terms of the GNU General Public License as published by  ##
## the Free Software Foundation; either version 2 of the License, or     ##
## (at your option) any later version.                                   ##
##                                                                       ##
###########################################################################
#!/bin/sh

# Ubuntu mirror server and mirror directory
#SOURCE_SRV=cn.archive.ubuntu.com
#SOURCE_SRV=archive.ubuntu.com
SOURCE_SRV=debian.ustc.edu.cn
SOURCE_DIR=/ubuntu

# Distribution, section and architecture list
DIST=precise,precise-security,precise-updates,precise-backports,precise-proposed
SECTION=main,main/debian-installer,restricted,restricted/debian-installer,universe,universe/debian-installer,multiverse,multiverse/debian-installer
ARCH=i386,amd64

# Local mirror directory
#MIRRORDIR=/var/ftp/pub/linux/ubuntu/
MIRRORDIR=/home/ubuntu/

# Log file
LOGFILE=/var/log/ubuntu_mirror.log

# Debug file (if you do not want to debug the download process set this option to "/dev/null")
DEBUGFILE=/var/log/ubuntu_mirror.debug

# Who will be informed in case if anything goes wrong (if you do not want to be informed via mail, set this option to "")
#MAILNOTIFY="root@localhost"

# Lock file
LOCK=/var/tmp/ubuntu_mirror.lock

##################################################################
# NORMALY THERE IS NO NEED TO CHANGE ANYTHING BELOW THIS COMMENT #
##################################################################

function log()
  {
    echo `date +%d.%m.%Y%t%H:%M:%S` "    LOG:" $1 >>${LOGFILE}
  }

function error()
  {
    echo `date +%d.%m.%Y%t%H:%M:%S` "    ERROR:" $1 >>${LOGFILE}
    if [ -n "$MAILNOTIFY" ] ; then
      echo `date +%d.%m.%Y%t%H:%M:%S` "    ERROR:" $1 | mail -s "ERROR while synchronizing Ubuntu" $MAILNOTIFY
    fi
       echo $1 | grep "Lockfile" >/dev/null
    if [ $? = 1 ] ; then
      rm -f ${LOCK}
    fi
    exit 1
  }

function status()
  {
    case "$1" in
      0)
        log "Synchronization completed."
        ;;
      1)
        error "DEBMIRROR: Connection closed"
        ;;
      2)
        error "DEBMIRROR: Timeout"
        ;;
      *)
        error "DEBMIRROR: Unknown error $1"
        ;;
    esac
  }

if [ -f ${LOCK} ] ; then
  error "Lockfile ${LOCK} exists."
fi

touch ${LOCK}

# Create local mirror directory if not exists
if [ ! -d ${MIRRORDIR} ] ; then
  log "Creating local mirror directory."
  mkdir -p ${MIRRORDIR}
fi

log "Starting Ubuntu download process."
debmirror -v -e http -h ${SOURCE_SRV} -r ${SOURCE_DIR} --ignore-release-gpg --dist=${DIST} --section=${SECTION} --arch=${ARCH} ${MIRRORDIR} >> ${DEBUGFILE} 2>&1
status $?

rm -f ${LOCK}

exit 0   


设置log

/etc/logrotate.d/ubuntu_mirror

 

/var/log/ubuntu_mirror.log {
    monthly
    rotate 3
    compress
    delaycompress
    missingok
    notifempty
}

/var/log/ubuntu_mirror.debug {
    weekly
    rotate 3
    compress
    delaycompress
    missingok
    notifempty
}

这个时候,就可以查看到log。目前我正在同步中。

 

注:参考沙克blog:www.chenshake.com

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值