Good to Know Database

Shell Skript: Ubuntu 10.04 Mirror Script


Das folgende Shell Skript erstellt einen lokalen Mirror für Ubuntu 10.04 (Lucid Lynx). Durch anpassen oder erweitern der Variable DIST kann dieses Skript auch für ältere und zukünftige Ubuntu Versionen verwendet werden.

Hinweis: Dieses Skript ist für CentOS 5.x ausgelegt und benötigt debmirror (siehe CentOS 5: debmirror installieren).

###########################################################################
##                                                                       ##
##                         Ubuntu Mirror Script                          ##
##                                                                       ##
## Creation:    06.07.2008                                               ##
## Last Update: 20.10.2013                                               ##
##                                                                       ##
## Copyright (c) 2008-2013 by Georg Kainzbauer <http://www.gtkdb.de>     ##
##                                                                       ##
## 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/bash

# Ubuntu mirror server and mirror directory
SOURCE_SRV=ftp-stud.fht-esslingen.de
SOURCE_DIR=/pub/Mirrors/ubuntu

# Distribution, section and architecture list
DIST=lucid,lucid-security,lucid-updates,lucid-backports,lucid-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/

# 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

###################################################################
# NORMALLY 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 -p -h ${SOURCE_SRV} -r ${SOURCE_DIR} --dist=${DIST} --section=${SECTION} --arch=${ARCH} --ignore-release-gpg ${MIRRORDIR} >> ${DEBUGFILE} 2>&1
status $?

rm -f ${LOCK}

exit 0


Dieser Eintrag wurde am 29.04.2010 erstellt und zuletzt am 24.01.2016 bearbeitet.

Direkter Link zu dieser Seite: http://www.gtkdb.de/index_33_959.html

[ Zur Startseite ]   [ Zur Kategorie ]


Valid XHTML 1.0 Transitional Valid CSS Valid Atom 1.0

© 2004-2018 by Georg Kainzbauer