Shell Skript: Fedora EPEL 6 Mirror Script
Das folgende Shell Skript erstellt einen lokalen Mirror des Fedora Extra Packages for Enterprise Linux (EPEL) 6 Repositories. Das lokale Mirror-Verzeichnis wird durch die Variable EPEL_6_MIRROR eingestellt.
Hinweis: Dieses Skript ist für CentOS 5.x ausgelegt.
###########################################################################
## ##
## Fedora EPEL 6 Mirror Script ##
## ##
## Creation: 26.11.2004 ##
## Last Update: 23.02.2014 ##
## ##
## Copyright (c) 2004-2014 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
# Fedora Extra Packages for Enterprise Linux (EPEL) mirror server and the local mirror directory
EPEL_6_SERVER=fedora.tu-chemnitz.de::fedora-epel/6/
EPEL_6_MIRROR=/var/ftp/pub/linux/fedora-epel/6/
# Log file
LOGFILE=/var/log/fedora-epel_6_mirror.log
# Debug file (if you do not want to debug the download process set this option to "/dev/null")
DEBUGFILE=/var/log/fedora-epel_6_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"
# Subject of the notification mail
MAILSUBJECT="ERROR while synchronizing Fedora EPEL 6 mirror"
# Lock file
LOCKFILE=/var/tmp/fedora-epel_6_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 | tee -a ${LOGFILE}
}
function error()
{
echo `date +%d.%m.%Y%t%H:%M:%S` " ERROR:" $1 | tee -a ${LOGFILE}
if [ -n "${MAILNOTIFY}" ] ; then
echo `date +%d.%m.%Y%t%H:%M:%S` " ERROR:" $1 | mail -s "${MAILSUBJECT}" ${MAILNOTIFY}
fi
}
function status()
{
case "$1" in
0)
log "Synchronization completed."
;;
1)
error "RSYNC: Syntax or usage error."
;;
2)
error "RSYNC: Protocol incompatibility."
;;
3)
error "RSYNC: Errors selecting input/output files, dirs."
;;
4)
error "RSYNC: Requested action not supported: an attempt was made to manipulate 64-bit files on a platform that cannot support them; or an option was specified that is supported by the client and not by the server."
;;
5)
error "RSYNC: Error starting client-server protocol."
;;
6)
error "RSYNC: Daemon unable to append to log-file."
;;
10)
error "RSYNC: Error in socket I/O."
;;
11)
error "RSYNC: Error in file I/O."
;;
12)
error "RSYNC: Error in rsync protocol data stream."
;;
13)
error "RSYNC: Errors with program diagnostics."
;;
14)
error "RSYNC: Error in IPC code."
;;
20)
error "RSYNC: Received SIGUSR1 or SIGINT."
;;
21)
error "RSYNC: Some error returned by waitpid()."
;;
22)
error "RSYNC: Error allocating core memory buffers."
;;
23)
error "RSYNC: Partial transfer due to error."
;;
24)
error "RSYNC: Partial transfer due to vanished source files."
;;
25)
error "RSYNC: The --max-delete limit stopped deletions."
;;
30)
error "RSYNC: Timeout in data send/receive."
;;
*)
error "RSYNC: Unknown error $1."
;;
esac
}
if [ -f ${LOCKFILE} ] ; then
kill -0 $(cat ${LOCKFILE}) >/dev/null 2>&1
if [ $? -eq 0 ] ; then
error "Previous process still running."
exit 1
else
log "Deprecated lock file found. Remove lock file."
rm -f ${LOCKFILE}
fi
fi
echo $$ >${LOCKFILE}
# Create local mirror directories if not exists
if [ ! -d ${EPEL_6_MIRROR} ] ; then
log "Creating local Fedora EPEL 6 mirror directory."
mkdir -p ${EPEL_6_MIRROR}
fi
log "Starting Fedora EPEL 6 download process."
echo ">>>>>" `date +%d.%m.%Y%t%H:%M:%S` "<<<<<" >>${DEBUGFILE}
rsync -av --delete --progress --delay-updates --timeout=300 --exclude "SRPMS" --exclude "ppc" ${EPEL_6_SERVER} ${EPEL_6_MIRROR} >>${DEBUGFILE} 2>&1
status $?
rm -f ${LOCKFILE}
exit 0
## ##
## Fedora EPEL 6 Mirror Script ##
## ##
## Creation: 26.11.2004 ##
## Last Update: 23.02.2014 ##
## ##
## Copyright (c) 2004-2014 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
# Fedora Extra Packages for Enterprise Linux (EPEL) mirror server and the local mirror directory
EPEL_6_SERVER=fedora.tu-chemnitz.de::fedora-epel/6/
EPEL_6_MIRROR=/var/ftp/pub/linux/fedora-epel/6/
# Log file
LOGFILE=/var/log/fedora-epel_6_mirror.log
# Debug file (if you do not want to debug the download process set this option to "/dev/null")
DEBUGFILE=/var/log/fedora-epel_6_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"
# Subject of the notification mail
MAILSUBJECT="ERROR while synchronizing Fedora EPEL 6 mirror"
# Lock file
LOCKFILE=/var/tmp/fedora-epel_6_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 | tee -a ${LOGFILE}
}
function error()
{
echo `date +%d.%m.%Y%t%H:%M:%S` " ERROR:" $1 | tee -a ${LOGFILE}
if [ -n "${MAILNOTIFY}" ] ; then
echo `date +%d.%m.%Y%t%H:%M:%S` " ERROR:" $1 | mail -s "${MAILSUBJECT}" ${MAILNOTIFY}
fi
}
function status()
{
case "$1" in
0)
log "Synchronization completed."
;;
1)
error "RSYNC: Syntax or usage error."
;;
2)
error "RSYNC: Protocol incompatibility."
;;
3)
error "RSYNC: Errors selecting input/output files, dirs."
;;
4)
error "RSYNC: Requested action not supported: an attempt was made to manipulate 64-bit files on a platform that cannot support them; or an option was specified that is supported by the client and not by the server."
;;
5)
error "RSYNC: Error starting client-server protocol."
;;
6)
error "RSYNC: Daemon unable to append to log-file."
;;
10)
error "RSYNC: Error in socket I/O."
;;
11)
error "RSYNC: Error in file I/O."
;;
12)
error "RSYNC: Error in rsync protocol data stream."
;;
13)
error "RSYNC: Errors with program diagnostics."
;;
14)
error "RSYNC: Error in IPC code."
;;
20)
error "RSYNC: Received SIGUSR1 or SIGINT."
;;
21)
error "RSYNC: Some error returned by waitpid()."
;;
22)
error "RSYNC: Error allocating core memory buffers."
;;
23)
error "RSYNC: Partial transfer due to error."
;;
24)
error "RSYNC: Partial transfer due to vanished source files."
;;
25)
error "RSYNC: The --max-delete limit stopped deletions."
;;
30)
error "RSYNC: Timeout in data send/receive."
;;
*)
error "RSYNC: Unknown error $1."
;;
esac
}
if [ -f ${LOCKFILE} ] ; then
kill -0 $(cat ${LOCKFILE}) >/dev/null 2>&1
if [ $? -eq 0 ] ; then
error "Previous process still running."
exit 1
else
log "Deprecated lock file found. Remove lock file."
rm -f ${LOCKFILE}
fi
fi
echo $$ >${LOCKFILE}
# Create local mirror directories if not exists
if [ ! -d ${EPEL_6_MIRROR} ] ; then
log "Creating local Fedora EPEL 6 mirror directory."
mkdir -p ${EPEL_6_MIRROR}
fi
log "Starting Fedora EPEL 6 download process."
echo ">>>>>" `date +%d.%m.%Y%t%H:%M:%S` "<<<<<" >>${DEBUGFILE}
rsync -av --delete --progress --delay-updates --timeout=300 --exclude "SRPMS" --exclude "ppc" ${EPEL_6_SERVER} ${EPEL_6_MIRROR} >>${DEBUGFILE} 2>&1
status $?
rm -f ${LOCKFILE}
exit 0
Damit die Logdateien nicht zu groß werden, sollten Sie Logrotate anweisen die Logdateien regelmäßig zu archivieren und nach einer gewissen Zeit zu löschen. Dazu erstellen Sie einfach die Datei /etc/logrotate.d/fedora-epel_6_mirror.
[root@centos5 ~]# vi /etc/logrotate.d/fedora-epel_6_mirror
Fügen Sie in diese Datei die folgenden Zeilen ein. Dadurch wird die Logdatei /var/log/fedora-epel_6_mirror.log monatlich und die Logdatei /var/log/fedora-epel_6_mirror.debug wöchentlich archiviert. Von beiden Logdateien werden nur die letzten drei Archivdateien vorgehalten. Ältere Archive werden automatisch gelöscht.
/var/log/fedora-epel_6_mirror.log {
monthly
rotate 3
compress
delaycompress
missingok
notifempty
}
/var/log/fedora-epel_6_mirror.debug {
weekly
rotate 3
compress
delaycompress
missingok
notifempty
}
monthly
rotate 3
compress
delaycompress
missingok
notifempty
}
/var/log/fedora-epel_6_mirror.debug {
weekly
rotate 3
compress
delaycompress
missingok
notifempty
}
Dieser Eintrag wurde am 13.02.2011 erstellt und zuletzt am 05.04.2015 bearbeitet.
Direkter Link zu dieser Seite: http://www.gtkdb.de/index_33_1163.html
[ Zur Startseite ] [ Zur Kategorie ]
© 2004-2021 by Georg Kainzbauer