Quelques notes sur la mise en place de mes miroirs

Les scripts

Fichier /usr/local/bin/miroir-ubuntu :

#!/bin/bash

MIROIR=cm.archive.ubuntu.com
VERBOSE="--verbose --progress"
DESTINATION=/var/www/ubuntu
DISTS=jaunty,jaunty-security,jaunty-updates,karmic,karmic-security,karmic-updates

debmirror -v -P --host=$MIROIR  \
 --arch=i386 --nosource --cleanup --method=http \
 --root=ubuntu --dist=$DISTS $VERBOSE \
 --section=main,main/debian-installer,restricted,restricted/debian-installer,multiverse,universe \
 $DESTINATION

Fichier /usr/local/bin/miroir-debian :

#!/bin/sh

BASEWWW=/var/www
DESTINATION=$BASEWWW/debian
OPENVZ=$BASEWWW/openvz
SERVEURSOURCE=ftp.fr.debian.org
ARCH=i386
SECTION=main,contrib,main/debian-installer
VERBOSE=" --verbose --progress "

debmirror -v -P --host=$SERVEURSOURCE \
 --arch=$ARCH --nosource --method=http \
 --root=debian $VERBOSE --dist=lenny,squeeze \
 --section=$SECTION \
 $DESTINATION 


debmirror -v -P --arch=$ARCH --host=security.debian.org --dist=lenny/updates,squeeze/updates \
--method=http --root=debian-security  --section=$SECTION $VERBOSE --nosource \
"$DESTINATION-security/"

Fichier /usr/local/bin/miroir-debian-volatile :

#!/bin/sh

BASEWWW=/var/www
DESTINATION=$BASEWWW/debian
SERVEURSOURCE=ftp.fr.debian.org
ARCH=i386
SECTION=main,contrib,main/debian-installer

debmirror -v -P --arch=$ARCH --host=$SERVEURSOURCE --dist=lenny/volatile,squeeze/volatile \
--method=http --root=debian-volatile  --section=main,contrib,non-free --nosource "$DESTINATION-volatile/"

À rendre exécutables :

miroir:/# ls -l /usr/local/bin/       
total 12
-rwxr-xr-x 1 root root 1271 Jul 24 10:50 miroir-debian
-rwxr-xr-x 1 root root  626 Jul 24 10:58 miroir-debian-volatile
-rwxr-xr-x 1 root root  776 Jul 24 10:50 miroir-ubuntu

Crontab

Fichier /etc/cron.d/miroir :

0 20 * * * miroir [ -x /usr/local/bin/miroir-debian ] && /usr/local/bin/miroir-debian 1>>/var/log/miroir/miroir-debian.log
0 00 * * * miroir [ -x /usr/local/bin/miroir-debian-volatile ] && /usr/local/bin/miroir/miroir-debian-volatile 1>>/var/log/miroir-debian-volatile.log
0 04 * * * miroir [ -x /usr/local/bin/miroir-ubuntu ] && /usr/local/bin/miroir-ubuntu 1>>/var/log/miroir/miroir-ubuntu.log

Logrotate

Fichier /etc/logrotate.d/miroir :

/var/log/miroir/miroir-ubuntu.log {
rotate 7
daily
compress
prerotate 
        cat /var/log/miroir/miroir-ubuntu.log | mail -s "Logs Ubuntu" root@cm.refer.org
endscript
dateext
}

/var/log/miroir/miroir-debian.log {
rotate 7
daily
compress
prerotate 
        cat /var/log/miroir/miroir-debian.log | mail -s "Logs Debian" root@cm.refer.org
endscript
dateext
}

/var/log/miroir/miroir-debian-volatile.log {
rotate 7
daily
compress
prerotate 
        cat /var/log/miroir/miroir-debian-volatile.log | mail -s "Logs Debian volatile" root@cm.refer.org
endscript
dateext
}

Normalement la ligne mail root@cm.refer.org devait suffire à m'envoyer une copie du log, mais ca marche pas chez moi, je sais pas pourquoi. Et meme quand ca le ferai, je préfère avoir le contenu du log directement dans le mail, plutot que de l'avoir comme fichier attaché (il faudrait encore l'ouvrir avant de le lire, et je suis pareusseux) => le prerotate.

Ajuster les droits:

miroir:/# ls -l /etc/logrotate.d/miroir 
-rw-r--r-- 1 root root 181 Jul 23 13:09 /etc/logrotate.d/miroir

Créer le répertoire de log. Voici à quoi ressemble le mien après un rotate:

miroir:/# ls /var/log/miroir/
miroir.log  miroir.log-20090724.gz

Une fois qu'on a bien configuré exim pour l'envoie des courriers (dpkg-reconfigure exim4-config), on peut aller se bronzer aux bahamas en attendant que les courriels nous signalent d'éventuelles erreurs (par exemple que je dois rajouter de l'espace disque chez moi :-P .

Quelques aménagements

Utilisateur ''miroir'' dédié

Si lors de l'exécution des scripts de mise à jour on recoit des messages du genre :

[0%] Getting: dists/lenny/updates/Release.gpg... ok
gpgv: keyblock resource `/root/.gnupg/trustedkeys.gpg': general error
gpgv: Signature made Sun Jul 26 13:12:04 2009 WAT using RSA key ID 55BE302B
[GNUPG:] ERRSIG 9AA38DCD55BE302B 1 2 00 1248610324 9
[GNUPG:] NO_PUBKEY 9AA38DCD55BE302B
gpgv: Can't check signature: public key not found
gpgv: keyblock resource `/root/.gnupg/trustedkeys.gpg': general error
gpgv: Signature made Sun Jul 26 13:12:04 2009 WAT using RSA key ID 55BE302B
gpgv: Can't check signature: public key not found
Release signature does not verify.

ou bien, on a l'autre symptôme suivant :

miroir:/# aptitude update
Hit http://miroir.cm.refer.org lenny Release.gpg
Get:1 http://miroir.cm.refer.org lenny/updates Release.gpg [197B]
Hit http://miroir.cm.refer.org lenny Release
Hit http://miroir.cm.refer.org lenny/updates Release
Ign http://miroir.cm.refer.org lenny/main Packages/DiffIndex
Get:2 http://miroir.cm.refer.org lenny/updates Release [40.8kB]
Hit http://miroir.cm.refer.org lenny/main Packages
Ign http://miroir.cm.refer.org lenny/updates Release
Ign http://miroir.cm.refer.org lenny/updates/main Packages/DiffIndex
Hit http://miroir.cm.refer.org lenny/updates/main Packages
Fetched 41.0kB in 0s (608kB/s)
Reading package lists... Done
W: GPG error: http://miroir.cm.refer.org lenny/updates Release: The following signatures were invalid: KEYEXPIRED 1246455239
W: You may want to run apt-get update to correct these problems

ou encore si on trouve ceci dans les logs :

W: GPG error: http://miroir.cm.auf.org lenny/updates Release: Les signatures suivantes ne sont pas valables : KEYEXPIRED 1246455239
W: Vous pouvez lancer « apt-get update » pour corriger ces problèmes.

alors, on peut procéder comme suit :

Les deuxièmes lignes (gpg --keyring suivi de gpg --no-default-keyring) permettent notamment d'éviter le premier symptôme cité ci-dessus.

Et voilà le travail, on peut faire les mises à jours sans soucis.

Fabriquer ses DVD/CD à partir de son miroir

Pour cela on peut utiliser jigdo.

  1. Installer jigdo et jigdo-file

  2. télécharger les fichiers .template et .jigdo correspondants soit aux DVD, soit aux CD que vous voulez télécharger à l'adresse http://cdimage.debian.org/debian-cd/5.0.4/i386/jigdo-dvd/ par exemple.

    nacer@nacer-adamou:~/Projets/debian-cd$ ls
    debian-504-i386-CD-1.template  debian-504-i386-CD-1.jigdo
  3. démarrer la construction de votre image iso :

    nacer@nacer-adamou:~/Projets/debian-cd$ jigdo-lite 
    nacer@nacer-adamou:~/Projets/debian-cd$ jigdo-lite 
    
    Jigsaw Download "lite"
    Copyright (C) 2001-2005  |  jigdo@
    Richard Atterer          |  atterer.net
    Getting mirror information from /etc/apt/sources.list
    
    -----------------------------------------------------------------
    To resume a half-finished download, enter name of .jigdo file.
    To start a new download, enter URL of .jigdo file.
    You can also enter several URLs/filenames, separated with spaces,
    or enumerate in {}, e.g. `http://server/cd-{1_NONUS,2,3}.jigdo'
    jigdo: debian-504-i386-DVD-1.jigdo
    -----------------------------------------------------------------
    Images offered by `debian-504-i386-DVD-2.jigdo':
      1: 'Debian GNU/Linux 5.0.4 "Lenny" - Official i386 DVD Binary-2 20100131-19:16 (20100131)' (debian-504-i386-DVD-2.iso)
    
    Further information about `debian-504-i386-DVD-2.iso':
    Generated on Sun, 31 Jan 2010 20:29:30 +0100
    
    -----------------------------------------------------------------
    If you already have a previous version of the CD you are
    downloading, jigdo can re-use files on the old CD that are also
    present in the new image, and you do not need to download them
    again. Mount the old CD ROM and enter the path it is mounted under
    (e.g. `/mnt/cdrom').
    Alternatively, just press enter if you want to start downloading
    the remaining files.
    Files to scan: 
    -----------------------------------------------------------------
    The jigdo file refers to files stored on Ubuntu mirrors. Please
    choose an Ubuntu mirror as follows: Either enter a complete URL
    pointing to a mirror (in the form
    `http://archive.ubuntu.com/archive/'), or enter any regular expression
    for searching through the list of mirrors: Try a two-letter
    country code such as `de', or a country name like `United
    States', or a server name like `sunsite'.
    Ubuntu mirror [http://miroir.cm.auf.org/ubuntu]: http://miroir.cm.auf.org/debian
  4. Il ne reste plus qu'à attendre que la génération du .iso se fasse. Repéter la procédure pour chacun des CD/DVD à créer et le tour est joué.

Enjoy!

NacerAdamouSaidou/Miroir (dernière édition le 2010-04-07 16:26:50 par JeanChristopheAndré)