Modifications entre les versions 1 et 11 (s'étendant sur 10 versions)
Version 1 à la date du 2009-07-24 10:03:15
Taille: 4485
Commentaire:
Version 11 à la date du 2010-04-07 15:34:59
Taille: 10435
Commentaire:
Texte supprimé. Texte ajouté.
Ligne 1: Ligne 1:
Rédiger « NacerAdamouSaidou/Miroir » ici.
Quelques notes sur la mise en place de mes miroir

= Les scripts = 
Quelques notes sur la mise en place de mes miroirs

== Les scripts ==
Ligne 15: Ligne 14:
LOG=/var/log/miroir/miroir.log

if [ ! -f $LOG ]; then
 touch $LOG
fi

echo -n "Debut de la synchronisation ubuntu -- " | tee -a $LOG
date | tee -a $LOG
echo "" >> $LOG

# --section=main,restricted,multiverse,universe \
Ligne 27: Ligne 15:
 --ignore-release-gpg --arch=i386 --nosource --method=http \
 --ignore-small-errors \
 --arch=i386 --nosource --cleanup --method=http \
Ligne 31: Ligne 18:
 $DESTINATION | tee -a $LOG 2>&1

echo "########################################################\n\n\n" >> $LOG
 $DESTINATION
Ligne 45: Ligne 31:
LOG=/var/log/miroir/miroir.log

if [ ! -f $LOG ]; then
        touch $LOG
fi

echo "Debut de la synchronisation Debian -- " | tee -a $LOG
date | tee -a $LOG
echo "" >> $LOG

# echo "Miroir de $DESTINATION depuis $SERVEURSOURCE"

debmirror -v -P --ignore-release-gpg --host=$SERVEURSOURCE \
 --ignore-release-gpg --arch=$ARCH --nosource --method=http \

debmirror -v -P --host=$SERVEURSOURCE \
 --arch=$ARCH --nosource --method=http \
Ligne 61: Ligne 36:
 $DESTINATION | tee -a $LOG 2>&1

# echo "Miroir de $DESTINATION-security depuis security.debian.org"


debmirror -v -P --ignore-release-gpg --arch=$ARCH --host=security.debian.org --dist=lenny/updates,squeeze/updates \
--method=ftp --root=debian-security --section=$SECTION $VERBOSE --nosource \
"$DESTINATION-security/" | tee -a $LOG 2>&1

echo "########################################################\n\n\n" >> $LOG
 $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/"
Ligne 79: Ligne 51:
LOG=/var/log/miroir/miroir.log
if [ ! -f $LOG ]; then
        touch $LOG
fi

echo -n "Debut de la synchronisation Debian volatile -- " >> $LOG
date >> $LOG
echo "" >> $LOG


debmirror -v -P --ignore-release-gpg --arch=$ARCH --host=$SERVEURSOURCE --dist=lenny/volatile,squeeze/volatile \
--method=http --root=debian-volatile --section=main,contrib,non-free --nosource "$DESTINATION-volatile/" >> $LOG 2>&1

echo "########################################################\n\n\n" >> $LOG


}}}

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/"

}}}
Ligne 104: Ligne 66:
= Crontab = == Crontab ==
Ligne 107: Ligne 69:
miroir:/# crontab -e
# m h dom mon dow command
00 20 * * * /usr/local/bin/miroir-ubuntu
00 00 * * * /usr/local/bin/miroir-debian
00 04 * * * /usr/local/bin/miroir-debian-volatile
}}}

= Logrotate =
miroir:/# vi /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 ==
Ligne 118: Ligne 79:
/var/log/miroir/miroir.log { /var/log/miroir/miroir-ubuntu.log {
Ligne 122: Ligne 83:
mail root@cm.refer.org
Ligne 124: Ligne 84:
 cat /var/log/miroir/miroir.log | mail -s "Logs miroir" root@cm.refer.org  cat /var/log/miroir/miroir-ubuntu.log | mail -s "Logs Ubuntu" root@cm.refer.org
Ligne 129: Ligne 89:
}}} /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
}

}}}
Ligne 146: Ligne 127:

== Quelques aménagements ==
=== Utilisateur ''miroir'' dédié ===
 * Créer un utilisateur miroir qui sera utilisé pour les mises à jour
{{{
miroir:~# adduser miroir
miroir:~# usermod -d /var/www miroir
miroir:~# chown miroir -R /var/www
miroir:~# adduser miroir sudo
miroir:~# cat /etc/sudoers
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification
Cmnd_Alias MIROIR = /usr/local/bin/miroir-ubuntu, \
  /usr/local/bin/miroir-debian, \
  /usr/local/bin/miroir-debian-volatile

# User privilege specification
root ALL=(ALL) ALL

%sudo ALL=NOPASSWD: MIROIR

miroir:~# chown miroir /var/log/miroir/miroir-*.log
}}}

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 reçoit 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:
 * on enlève l'option --ignore-release-gpg de debmirror dans les scripts de mise à jour
 * on installe les paquets debian-archive-keyring et ubuntu-archive-keyring respectivement (si c'est pas fait déjà).
 * on installe les clés correspondantes:
{{{
miroir:~# su - miroir
miroir@miroir:~$ gpg --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 # vérifier la pertinence de cette ligne si ubuntu-archive-keyring est installée
miroir@miroir:~$ gpg --keyring /usr/share/keyrings/ubuntu-archive-keyring.gpg --export | gpg --no-default-keyring --keyring trustedkeys.gpg --import
}}}
pour ubuntu, et
{{{
miroir@miroir:~$ gpg --keyserver subkeys.pgp.net --recv-keys 55BE302B # vérifier la pertinence de cette ligne si debian-archive-keyring est installée
miroir@miroir:~$ gpg --keyring /usr/share/keyrings/debian-archive-keyring.gpg --export | gpg --no-default-keyring --keyring trustedkeys.gpg --import
}}}
pour debian.

Les deuxième ligne (gpg --keyring suivi de gpg --no-default-keyring) permet 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é.
'''Just enjoy'''

Quelques notes sur la mise en place de mes miroirs

Les scripts

miroir:/# cat /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


miroir:/# cat /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/"

miroir:/# cat /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/"

A rendre exécutable

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

miroir:/# vi /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

miroir:/# cat /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é

  • Créer un utilisateur miroir qui sera utilisé pour les mises à jour

miroir:~# adduser miroir
miroir:~# usermod -d /var/www miroir
miroir:~# chown miroir -R /var/www
miroir:~# adduser miroir sudo
miroir:~# cat /etc/sudoers
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults        env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification
Cmnd_Alias      MIROIR = /usr/local/bin/miroir-ubuntu, \
                /usr/local/bin/miroir-debian, \
                /usr/local/bin/miroir-debian-volatile

# User privilege specification
root    ALL=(ALL) ALL

%sudo ALL=NOPASSWD: MIROIR

miroir:~# chown miroir /var/log/miroir/miroir-*.log

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 reçoit 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:

  • on enlève l'option --ignore-release-gpg de debmirror dans les scripts de mise à jour
  • on installe les paquets debian-archive-keyring et ubuntu-archive-keyring respectivement (si c'est pas fait déjà).
  • on installe les clés correspondantes:

miroir:~# su - miroir
miroir@miroir:~$ gpg --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5   # vérifier la pertinence de cette ligne si ubuntu-archive-keyring est installée
miroir@miroir:~$ gpg --keyring /usr/share/keyrings/ubuntu-archive-keyring.gpg --export | gpg --no-default-keyring --keyring trustedkeys.gpg --import

pour ubuntu, et

miroir@miroir:~$ gpg --keyserver subkeys.pgp.net --recv-keys 55BE302B  # vérifier la pertinence de cette ligne si debian-archive-keyring est installée
miroir@miroir:~$ gpg --keyring /usr/share/keyrings/debian-archive-keyring.gpg --export | gpg --no-default-keyring --keyring trustedkeys.gpg --import

pour debian.

Les deuxième ligne (gpg --keyring suivi de gpg --no-default-keyring) permet 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
  1. 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
  1. 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é.

Just enjoy

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