tachtler:repository_spiegeln_centos_7
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
tachtler:repository_spiegeln_centos_7 [2014/12/12 14:14] – klaus | tachtler:repository_spiegeln_centos_7 [2014/12/12 15:00] (aktuell) – [Befehl: rsync] klaus | ||
---|---|---|---|
Zeile 181: | Zeile 181: | ||
transferieren würde! | transferieren würde! | ||
< | < | ||
- | # / | + | # / |
- | --exclude SRPMS/ ftp-stud.fht-esslingen.de:: | + | |
Welcome to the ftp-stud.hs-esslingen.de archives. | Welcome to the ftp-stud.hs-esslingen.de archives. | ||
Zeile 222: | Zeile 221: | ||
Mit nachfolgendem Befehl, kann der so eben transferierte Inhalt, angezeigt werden: | Mit nachfolgendem Befehl, kann der so eben transferierte Inhalt, angezeigt werden: | ||
< | < | ||
- | # ls -la /tmp/test | + | # ls -l /tmp/test |
+ | total 23548 | ||
+ | -rw-r--r-- 1 406 75 2466737 Jul 4 18:00 1a7dd0d315b39ad504f54ea88676ab502a48064cb2d875ae3ae29431e175861c-primary.xml.gz | ||
+ | -rw-r--r-- 1 406 75 725755 Jul 4 18:01 2bc0054a9f0f4cd3d2806d983edbe3d0dfc484d9f275d12be79eb67a040ba942-c7-x86_64-comps.xml | ||
+ | -rw-r--r-- 1 406 75 6048365 Jul 4 18:01 3cda64d1c161dd0fead8398a62ef9c691e78ee02fe56d04566f850c94929f61f-filelists.sqlite.bz2 | ||
+ | -rw-r--r-- 1 406 75 160516 Jul 4 18:01 4b9ac2454536a901fecbc1a5ad080b0efd74680c6e1f4b28fb2c7ff419872418-c7-x86_64-comps.xml.gz | ||
+ | -rw-r--r-- 1 406 75 6024471 Jul 4 18:00 7a90ec1358cb1d9cab4c84793f9b96602fb49e7db90a6b8f5ddc441cb2a918c6-filelists.xml.gz | ||
+ | -rw-r--r-- 1 406 75 1305746 Jul 4 18:00 ea8bacdf833619ea843887b0673a569633dc9853462219b50578d8247a1cf6c0-other.xml.gz | ||
+ | -rw-r--r-- 1 406 75 5161398 Jul 4 18:01 efa521576f53587de26616ea1e45f902993abcd9d67e707b8993b5f29bd15956-primary.sqlite.bz2 | ||
+ | -rw-r--r-- 1 406 75 2198161 Jul 4 18:00 fdef8b31072b60b0cad9c0c63977ff9c5fb5080f3ecdb47bff0ec0b7bf9b7855-other.sqlite.bz2 | ||
+ | -rw-r--r-- 1 406 75 3735 Jul 4 18:01 repomd.xml | ||
</ | </ | ||
Zeile 229: | Zeile 238: | ||
# rm /tmp/test -rf | # rm /tmp/test -rf | ||
</ | </ | ||
+ | |||
+ | ===== Script: rsync_centos70.sh ===== | ||
+ | |||
+ | Mit nachfolgendem Script, kann nun z.B. Zeitgesteuert durch einen **'' | ||
+ | |||
+ | :!: **HINWEIS** - **Bitte __bei der ERSTEN__ Ausführung bedenken, dass je nach eigener Anbindung ans Internet, eine __sehr__ lange Datentransferzeit zu erwarten ist !!!** | ||
+ | |||
+ | :!: **WICHTIG** - Bei einer **__eignen__ Internetanbindung** mit **__hoher Bandbreite__** sollte noch der '' | ||
+ | * < | ||
+ | hinzugefügt werden, um in diesem Beispiel die [[http:// | ||
+ | | ||
+ | |||
+ | Der Inhalt des Scripts, sieht wie folgt aus: | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | ############################################################################## | ||
+ | # Script-Name : rsync_centos70.sh | ||
+ | # Description : Script to sync via rsync command repositorys from official | ||
+ | # | ||
+ | # be written. On error while execution, a LOG file and a error # | ||
+ | # | ||
+ | # # | ||
+ | # Last update : 12.12.2014 | ||
+ | # Version | ||
+ | # # | ||
+ | # Author | ||
+ | # DokuWiki | ||
+ | # Homepage | ||
+ | # # | ||
+ | # Base script : centos6.0_mirror.sh, | ||
+ | # created by : Georg Kainzbauer, < | ||
+ | # Homepage | ||
+ | # # | ||
+ | # +----------------------------------------------------------------------+ | ||
+ | # | 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. | ||
+ | # +----------------------------------------------------------------------+ | ||
+ | # # | ||
+ | # Copyright (c) 2011 by Klaus Tachtler. | ||
+ | # # | ||
+ | ############################################################################## | ||
+ | |||
+ | ############################################################################## | ||
+ | # H I S T O R Y # | ||
+ | ############################################################################## | ||
+ | # Version | ||
+ | # Description : < | ||
+ | # -------------------------------------------------------------------------- # | ||
+ | # Version | ||
+ | # Description : < | ||
+ | # -------------------------------------------------------------------------- # | ||
+ | ############################################################################## | ||
+ | |||
+ | ############################################################################## | ||
+ | # >>> | ||
+ | ############################################################################## | ||
+ | |||
+ | # CUSTOM - Script-Name. | ||
+ | SCRIPT_NAME=' | ||
+ | |||
+ | # CUSTOM - Command-Line. | ||
+ | RSYNC_CMDOPTS=' | ||
+ | RSYNC_EXCLUDE=' | ||
+ | |||
+ | # CUSTOM - Repository-Mirrors. | ||
+ | REPO_SOURCE=' | ||
+ | # | ||
+ | # | ||
+ | REPO_TARGET='/ | ||
+ | LINK_TARGET='/ | ||
+ | |||
+ | # CUSTOM - Mail-Recipient. | ||
+ | MAIL_RECIPIENT=' | ||
+ | |||
+ | # CUSTOM - Status-Mail [Y|N]. | ||
+ | MAIL_STATUS=' | ||
+ | |||
+ | ############################################################################## | ||
+ | # >>> | ||
+ | ############################################################################## | ||
+ | |||
+ | # Variables. | ||
+ | RSYNC_COMMAND=`command -v rsync` | ||
+ | TOUCH_COMMAND=`command -v touch` | ||
+ | RM_COMMAND=`command -v rm` | ||
+ | PROG_SENDMAIL=`command -v sendmail` | ||
+ | CAT_COMMAND=`command -v cat` | ||
+ | DATE_COMMAND=`command -v date` | ||
+ | MKDIR_COMMAND=`command -v mkdir` | ||
+ | LN_COMMAND=`command -v ln` | ||
+ | FILE_LOCK='/ | ||
+ | FILE_LOG='/ | ||
+ | FILE_LAST_LOG='/ | ||
+ | FILE_MAIL='/ | ||
+ | VAR_HOSTNAME=`uname -n` | ||
+ | VAR_SENDER=' | ||
+ | VAR_EMAILDATE=`$DATE_COMMAND '+%a, %d %b %Y %H:%M:%S (%Z)'` | ||
+ | |||
+ | # Functions. | ||
+ | function log() { | ||
+ | echo $1 | ||
+ | echo `$DATE_COMMAND ' | ||
+ | } | ||
+ | |||
+ | function retval() { | ||
+ | if [ " | ||
+ | case " | ||
+ | 1) | ||
+ | log " | ||
+ | ;; | ||
+ | 2) | ||
+ | log " | ||
+ | ;; | ||
+ | 3) | ||
+ | log " | ||
+ | ;; | ||
+ | 4) | ||
+ | log " | ||
+ | ;; | ||
+ | 5) | ||
+ | log " | ||
+ | ;; | ||
+ | 6) | ||
+ | log " | ||
+ | ;; | ||
+ | 10) | ||
+ | log " | ||
+ | ;; | ||
+ | 11) | ||
+ | log " | ||
+ | ;; | ||
+ | 12) | ||
+ | log " | ||
+ | ;; | ||
+ | 13) | ||
+ | log " | ||
+ | ;; | ||
+ | 14) | ||
+ | log " | ||
+ | ;; | ||
+ | 20) | ||
+ | log " | ||
+ | ;; | ||
+ | 21) | ||
+ | log " | ||
+ | ;; | ||
+ | 22) | ||
+ | log " | ||
+ | ;; | ||
+ | 23) | ||
+ | log " | ||
+ | ;; | ||
+ | 24) | ||
+ | log " | ||
+ | ;; | ||
+ | 25) | ||
+ | log " | ||
+ | ;; | ||
+ | 30) | ||
+ | log " | ||
+ | ;; | ||
+ | *) | ||
+ | log " | ||
+ | ;; | ||
+ | esac | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | function movelog() { | ||
+ | $CAT_COMMAND $FILE_LAST_LOG >> $FILE_LOG | ||
+ | $RM_COMMAND -f $FILE_LAST_LOG | ||
+ | $RM_COMMAND -f $FILE_LOCK | ||
+ | } | ||
+ | |||
+ | function sendmail() { | ||
+ | case " | ||
+ | ' | ||
+ | MAIL_SUBJECT=' | ||
+ | ;; | ||
+ | *) | ||
+ | MAIL_SUBJECT=' | ||
+ | ;; | ||
+ | esac | ||
+ | |||
+ | $CAT_COMMAND << | ||
+ | Subject: $MAIL_SUBJECT | ||
+ | Date: $VAR_EMAILDATE | ||
+ | From: $VAR_SENDER | ||
+ | To: $MAIL_RECIPIENT | ||
+ | |||
+ | |||
+ | |||
+ | $CAT_COMMAND $FILE_LAST_LOG >> $FILE_MAIL | ||
+ | |||
+ | $PROG_SENDMAIL -f $VAR_SENDER -t $MAIL_RECIPIENT < $FILE_MAIL | ||
+ | |||
+ | $RM_COMMAND -f $FILE_MAIL | ||
+ | |||
+ | } | ||
+ | |||
+ | # Main. | ||
+ | log "" | ||
+ | log " | ||
+ | log "| Start synchronisation from official repository server (mirror). |" | ||
+ | log " | ||
+ | log "" | ||
+ | log "Run script with following parameter:" | ||
+ | log "" | ||
+ | log " | ||
+ | log "" | ||
+ | log " | ||
+ | log " | ||
+ | log "" | ||
+ | log " | ||
+ | log " | ||
+ | log " | ||
+ | log "" | ||
+ | log " | ||
+ | log " | ||
+ | log "" | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 10 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 11 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 12 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 13 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 14 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 15 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 16 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 17 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if LOCK file NOT exist. | ||
+ | if [ ! -e " | ||
+ | log "Check if script is NOT already runnig .....................[ | ||
+ | |||
+ | $TOUCH_COMMAND $FILE_LOCK | ||
+ | else | ||
+ | log "Check if script is NOT already runnig .....................[FAILED]" | ||
+ | log "" | ||
+ | log " | ||
+ | log "" | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 20 | ||
+ | fi | ||
+ | |||
+ | # Check if REPO_TARGET Directory NOT exists. | ||
+ | if [ ! -d " | ||
+ | log "Check if REPO_TARGET exists................................[FAILED]" | ||
+ | log "" | ||
+ | log " INFO: Creating REPO_TARGET!" | ||
+ | log " INFO: --> " | ||
+ | log "" | ||
+ | |||
+ | $MKDIR_COMMAND -p $REPO_TARGET | ||
+ | else | ||
+ | log "Check if REPO_TARGET exists................................[ | ||
+ | fi | ||
+ | |||
+ | # Check if LINK_TARGET symbolic Link NOT exists. | ||
+ | if [ ! -L " | ||
+ | log "Check if LINK_TARGET exists................................[FAILED]" | ||
+ | log "" | ||
+ | log " INFO: Creating LINK_TARGET!" | ||
+ | log " INFO: --> " | ||
+ | log "" | ||
+ | |||
+ | $LN_COMMAND -fs $REPO_TARGET $LINK_TARGET | ||
+ | else | ||
+ | log "Check if LINK_TARGET exists................................[ | ||
+ | fi | ||
+ | |||
+ | # Start syncing. | ||
+ | log "" | ||
+ | log " | ||
+ | log "| Run synchronizing $SCRIPT_NAME repository.................... |" | ||
+ | log " | ||
+ | log "" | ||
+ | |||
+ | log " | ||
+ | |||
+ | $RSYNC_COMMAND $RSYNC_CMDOPTS --log-file=$FILE_LAST_LOG $RSYNC_EXCLUDE $REPO_SOURCE $REPO_TARGET | ||
+ | |||
+ | if [ " | ||
+ | retval $? | ||
+ | log "" | ||
+ | $RM_COMMAND -f $FILE_LOCK | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 99 | ||
+ | else | ||
+ | log "" | ||
+ | log " | ||
+ | log "| End synchronizing $SCRIPT_NAME repository.................... |" | ||
+ | log " | ||
+ | log "" | ||
+ | fi | ||
+ | |||
+ | # Finish syncing. | ||
+ | log " | ||
+ | log "| Finish......................................................... |" | ||
+ | log " | ||
+ | log "" | ||
+ | |||
+ | # Status e-mail. | ||
+ | if [ $MAIL_STATUS = ' | ||
+ | sendmail STATUS | ||
+ | fi | ||
+ | # Move temporary log to permanent log | ||
+ | movelog | ||
+ | |||
+ | exit 0 | ||
+ | </ | ||
+ | |||
+ | **__Das Script hat folgende WICHTIGE Merkmale: | ||
+ | * Konfigurierbare Parameter | ||
+ | * Überprüfung ob alle Befehle zur erfolgreichen Ausführung verfügbar sind (Evtl. wichtig für Portierungen) | ||
+ | * Ausführungsschutz, | ||
+ | * Ausgabe von Laufzeitinformationen | ||
+ | * auf dem Bildschirm zur Laufzeit | ||
+ | * als **LOG**-Datei | ||
+ | * als **e-Mail** | ||
+ | * e-Mail Benachrichtigung im Fehlerfall | ||
+ | * **optional** e-Mail Benachrichtigung bei erfolgreicher Ausführung | ||
+ | |||
+ | ==== Einbindung als cron-job ==== | ||
+ | |||
+ | Nachfolgend soll das oben genannte Script als **'' | ||
+ | |||
+ | Dazu sollte als erstes nachfolgendes Verzeichnis | ||
+ | * **''/ | ||
+ | mit nachfolgendem Befehl erstellt werden: | ||
+ | < | ||
+ | # mkdir /root/bin/ | ||
+ | </ | ||
+ | |||
+ | Anschließend sollte das Script, in dem mit obigem Befehl erstellte Verzeichnis hinterlegt werden. Das Verzeichnis sollte wie folgt aussehen, was mit nachfolgendem Befehl überprüft werden kann: | ||
+ | < | ||
+ | # ls -l /root/bin | ||
+ | total 56 | ||
+ | -rw-r--r-- | ||
+ | </ | ||
+ | |||
+ | Evtl. sollten noch die Dateirechte mit nachfolgendem Befehl, wie folgt angepasst werden: | ||
+ | < | ||
+ | # chmod 750 / | ||
+ | </ | ||
+ | |||
+ | Eine erneute Abfrage des Verzeichnisses mit nachfolgendem Befehl sollte dann eine Ausgabe in etwa wie folgende ergeben: | ||
+ | < | ||
+ | # ls -l /root/bin | ||
+ | total 56 | ||
+ | -rwxr-xr-x | ||
+ | </ | ||
+ | |||
+ | === 1. Möglichkeit ==== | ||
+ | |||
+ | Einbindung des Scripts zur Ausführung als **'' | ||
+ | * **''/ | ||
+ | welches in diesem Fall eine Ausführung des Scripts **täglich** um **02:00 Uhr (nachts)** veranlassen würde. | ||
+ | |||
+ | Was durch hinzufügen von nachfolgender Zeile zur Konfigurationsdatei **''/ | ||
+ | <code ini> | ||
+ | ... | ||
+ | 00 02 * * * root / | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | === 2. Möglichkeit ==== | ||
+ | |||
+ | Einbindung eines **Links** auf das Scripts, zur Ausführung als **'' | ||
+ | * **''/ | ||
+ | welches in diesem Fall eine Ausführung des Scripts **täglich** je nach Konfiguration in der Konfigurationsdatei | ||
+ | * **''/ | ||
+ | hier als **Standard** zwischen **03: | ||
+ | |||
+ | Dies kann durch Ausführen des nachfolgenden Befehls erfolgen: | ||
+ | < | ||
+ | # ln -fs / | ||
+ | </ | ||
+ | |||
+ | Zu Überprüfung, | ||
+ | < | ||
+ | # ls -l / | ||
+ | total 8 | ||
+ | -rwxr-xr-x. 1 root root 332 Jun 27 13:07 0yum-daily.cron | ||
+ | -rwx------. 1 root root 180 Jul 31 2013 logrotate | ||
+ | -rwxr-xr-x. 1 root root 618 Mar 17 2014 man-db.cron | ||
+ | lrwxrwxrwx | ||
+ | </ | ||
+ | |||
+ | ==== Logrotate ==== | ||
+ | |||
+ | Das Script **''/ | ||
+ | * **''/ | ||
+ | |||
+ | Um das stetige Anwachsen und die Größe dieser **LOG**-Datei nicht ins unendliche zu treiben, wäre es sinnvoll die **LOG**-Datei mit **Linux**-Bordmitteln in regelmäßigen Abständen zu rotieren. | ||
+ | |||
+ | Dies kann durch die Anlage eines **neuen**, nachstehend gezeigten Scripts, erfolgen. Der Speicherort muss hier: | ||
+ | * **''/ | ||
+ | sein und das Script kann folgenden Namen tragen: | ||
+ | * **'' | ||
+ | |||
+ | Der Inhalt des Scripts **''/ | ||
+ | <code ini> | ||
+ | / | ||
+ | weekly | ||
+ | rotate 4 | ||
+ | compress | ||
+ | delaycompress | ||
+ | missingok | ||
+ | notifempty | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Demnach wird die **LOG**-Datei nach nachfolgenden Regeln rotiert: | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
tachtler/repository_spiegeln_centos_7.1418390082.txt.gz · Zuletzt geändert: 2014/12/12 14:14 von klaus