[Ubuntu-BR] [AJUDA]Mirror de ubuntu
Worlen Augusto Gomes
worlen.cdc em gmail.com
Domingo Março 10 23:42:11 UTC 2013
Boa tarde,
Estou desenvolvendo um mirror dos arquivos de CD e atualizações do
ubuntu(CD-mirrors e archive-mirrors) com base no script disponível em
http://sft.if.usp.br/sbin/mirror-debian-cd.
Realizei as modificações devidas gerando o seguinte script(logo
abaixo) para fazer o CD-mirrors.
Breve resumo:
Nesse script realizo a transferência dos arquivos do mirror usando o
rsync por meio de um link de repositório oficial que pode ser
encontrado nesse site:
https://launchpad.net/ubuntu/+cdmirrors
Após o término da transferência o rsync me retorna uma mensagem
informando se houve algum problema, que no caso do CD-mirrors, após o
termino da transferência ocorreu
tudo bem.
Porém, quando rodo esse script para baixar os arquivos do
archive-mirror, ao final da transferência o rsync me retorna a
seguinte mensagem que está hospedada a imagem em:
http://imageshack.us/photo/my-images/12/mirroredito.png/
Devido a esse problema ele deixa de baixar ou perde alguns arquivos
(não sei o que acontece realmente), e quando rodo novamente o script
que deveria baixar somente os arquivos que estavam faltando, isso não
ocorre, o script começa a baixar tudo do inicio.
Quando faço a transferência do CD-mirror esse problema não ocorre,
porém para o archive-mirror esse problema ocorre.
* Tentei links de repositórios oficiais diferente para transferência
* Não é problema de espaço em disco
e o problema continua.
Tamanho do CD-mirror: por volta de 40GB
Tamanho do Archive-mirror: por volta de 656GB.
Abaixo segue o script:
#!/bin/tcsh -f
# JLdL 11Mar11.
#
# Este é o roteiro de espelhamento do Ubuntu-CD usando o rsync;
# Este é para as versões mais recentes do Ubuntu (8.04 à 12.10);
#
# Versões mais antigas do Kubuntu e Edubuntu estão disponíveis aqui.
#
#
#
#
#
#
#
#
# Este script tem as seguintes características técnicas:
# _ 1) Tem um mecanismo de bloqueio local, de modo a evitar
# _ Duas instâncias do programa de execução no
# _ Mesmo tempo no servidor local.
# _ 2) Ele faz o bloqueio padrão universal dentro da raiz
# _ Diretório do espelho, de modo a informar
# _ Espelhos de uma atualização em andamento.
# _ 3) Verifica-se que mesmo bloqueio no servidor upstream,
# _ E aguarda a atualização terminar lá antes
# _ Iniciar a atualização do espelho local.
# _ 4) Ele usa as opções rsync "--delete-after" e
# _ "--Delay-updates", a fim de minimizar tamanho do espelho
# _ O tempo de inatividade para os usuários durante a atualização.
# _ 5) Ele tem um modo interativo e um modo em lote, este
# _ Uma última para ser executado a partir de um trabalho do cron, por meio
# _ De um link simbólico <file> lote. Apontando para este arquivo.
# _ 6) Cria o arquivo de timestamp local correta, usando
# _ O nome simbólico deste site, dentro do
# _ Subdiretório project/trace, se ele existir.
#
# PART 1: preparation: setting all the necessary variables.
#
# Section 1A: variables that may need customization.
#
# Define the root of the mirror filesystem.
set root = /
#
# Define the directory containing the mirror.
set mdir = $root/mirror/ubuntu-cd/
#
# Define the symbolic name of this site.
set site = br.releases.ubuntu.com
#
# Define the name of the remote host.
#set rhst = mirror.pop-sc.rnp.br
set rhst = mirror.pop-sc.rnp.br
#
# Define the remote rsync URL address.
set rurl = "rsync://$rhst/mirror/ubuntu/"
#
# Section 1B: variables that should need no customization.
#
# Define a filename for control purposes.
set file = `basename $0 | cut -d. -f1`
#
# Set the batch-mode flag.
if ( `basename $0 | cut -d. -f2` == batch ) then
set btch = 1
else
set btch = 0
endif
#
# Define the lock directory.
set lckd = /var/lock$root
#
# Define the lock file.
set lock = $lckd/$file
#
# Define the log directory.
set logd = $root/log-ubuntu-cd-mirror
#
# Define the error file.
set errf = $logd/$file.err
#
# Define the log file.
set logf = $logd/$file.log
#
# Define the maximum number of files to delete.
set maxd = 10000
#
# Define the temporary directory.
set tmpd = $root/tmp
#
# Define the name of the standard flag for the update.
set flag = Archive-Update-in-Progress
#
# Use the symbolic name of the site for the local flag.
set lflg = $flag-$site
#
# Use the name of the remote host for remote flag.
set rflg = $flag-$rhst
#
# Build an exclusion list for files and directories.
set excl = ""
#
# Exclude the default temporary directories used by rsync
# _ when the "--delay-updates" option is in effect.
set excl = "$excl --exclude \.\~tmp\~"
#
# Build a list of options for rsync, so that it will
# _ work well in mirror mode.
set opts = ""
set opts = "$opts --recursive"
set opts = "$opts --times"
set opts = "$opts --links"
set opts = "$opts --hard-links"
set opts = "$opts --delete"
set opts = "$opts --delete-after"
set opts = "$opts --max-delete=$maxd"
set opts = "$opts --delay-updates"
#set opts = "$opts --compress"
set opts = "$opts --verbose"
set opts = "$opts --partial"
set opts = "$opts --temp-dir=$tmpd"
set opts = "$opts --stats"
set opts = "$opts --human-readable"
#
# PART 2: the action within the mirror filesystem.
#
# Make sure that the mirror directory exists.
if ( ! -d $mdir ) then
mkdir $mdir
endif
#
# Make sure that the lock directory exists.
if ( ! -d $lckd ) then
mkdir $lckd
endif
#
# Make sure that the log directory exists.
if ( ! -d $logd ) then
mkdir $logd
endif
#
# Make sure that the temporary directory exists.
if ( ! -d $tmpd ) then
mkdir $tmpd
endif
#
# Go to the appropriate directory in the mirror filesystem.
cd $mdir
#
# Check for a lock file.
if ( -f $lock ) then
echo "${file}: this script is already running" | tee $errf
exit 1
endif
#
# Make a lock file.
touch $lock
#
# On interruption, go to the clean exit label; note that this
# _ does not work for unexpected errors within the commands
# _ called from this script.
onintr cleanexit
#
# Verify whether the upstream archive is being updated at this time;
# _ if it is, then wait and try again until that update is finished;
# _ however, only do this if running in batch mode.
if ( $btch ) then
#
# Start the log file.
cat /dev/null >&! $logf
#
# Start a trial counter.
set trl = 1
#
# A label for the waiting loop.
testagain:
#
# Try to simply list the flag file at the upstream site.
#rsync $rurl$flag-\* >& /dev/null
rsync $rurl$rflg >& /dev/null
#
# Keep the exit status in a separate variable.
set stat = $status
#
# If the transfer was successful, the update archive is being
# _ updated at this time, so wait for that update to finish;
# _ however, the transfer may have failed for some other
# _ reason, besides the flag file being absent, so there
# _ is more then one alternative to be tested; in any
# _ case retry every five minutes until it succeeds,
# _ up to a certain maximum number of times.
#
# Error code 23 means that the server was successfully
# _ connected but the transfer failed, meaning that
# _ the file requested was not found; this is the
# _ sole situation in which we proceed.
if ( $stat != 23 ) then
#
# Error code 0 means that the transfer was successful.
if ( $stat == 0 ) then
#
# Write a status message in the log file.
( echo -n "Upstream archive being updated on " ; date ) >>& $logf
#
# Other error codes probably mean that the connection
# _ to the server failed for some reason.
else
#
# Write a status message in the log file.
( echo -n "Error accessing upstream server $rhst on " ; \
date ) >>& $logf
#
endif
#
# Go to the next trial.
@ trl = $trl + 1
#
# Try up to 60 times (5 hours).
if ( $trl <= 60 ) then
#
# Wait for 5 minutes.
sleep 300
#
# Go back and try again.
goto testagain
#
else
#
# Exit cleanly.
goto cleanexit
#
endif
#
endif
#
# Clean up the log file.
cat /dev/null >&! $logf
#
# Run in interactive mode.
else
#
# Try to simply list the flag file at the upstream site.
#rsync $rurl$flag-\* >& /dev/null
rsync $rurl$rflg >& /dev/null
#
# Keep the exit status in a separate variable.
set stat = $status
#
# If the transfer was successful, the update archive is being
# _ updated at this time, therefore simply quit.
if ( $stat == 0 ) then
#
# Write out an error message and quit.
echo "${file}: ERROR: upstream archive being updated"
#
# Exit cleanly.
goto cleanexit
#
endif
#
endif
#
# Raise the standard universal flag during the update.
touch $lflg
#
# Disable shell expansion of the "*" character which
# _ may be contained in the excl variable.
set noglob
#
# Use rsync with all options and exclusions; if it fails, then
# _ try again, but only do this if running in batch mode.
if ( $btch ) then
#
# Start a trial counter.
set trl = 1
#
# A label for error handling.
again:
#
# Start the log file with the date.
( echo -n "Starting trial $trl on " ; date ) >&! $logf
#
# Run the mirror, logging to the log file.
rsync $opts $excl $rurl . >>& $logf
#
# Keep the exit status in a separate variable.
set stat = $status
#
# Retry every five minutes until it succeeds,
# _ up to a certain maximum number of times.
if ( $stat != 0 ) then
#
# Go to the next trial.
@ trl = $trl + 1
#
# Try up to 60 times (5 hours).
if ( $trl <= 60 ) then
#
# Wait for 5 minutes.
sleep 300
#
# Go back and try again.
goto again
#
endif
#
endif
#
# End the log file with the date.
( echo -n "Finished on " ; date ) >>& $logf
#
# Fix the log file.
/sft/sbin/doit-fix-log-file $logf
#
# Run in interactive mode.
else
rsync $opts --progress $excl $rurl .
endif
#
# Restore shell expansion of special characters.
unset noglob
#
# Lower the standard universal flag for the update.
if ( -f $lflg ) then
rm -f $lflg
endif
#
# Update the local timestamp file in the trace directory.
if ( -d project/trace ) then
date -u >! project/trace/$site
endif
#
# Remove the lock file.
cleanexit:
rm -f $lock
--
More information about the ubuntu-br
mailing list