diff options
Diffstat (limited to 'zarb-ml/mageia-dev/2012-November/019735.html')
-rw-r--r-- | zarb-ml/mageia-dev/2012-November/019735.html | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/zarb-ml/mageia-dev/2012-November/019735.html b/zarb-ml/mageia-dev/2012-November/019735.html new file mode 100644 index 000000000..15009daa7 --- /dev/null +++ b/zarb-ml/mageia-dev/2012-November/019735.html @@ -0,0 +1,166 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<HTML> + <HEAD> + <TITLE> [Mageia-dev] Distrib-coffee big failure of the century + </TITLE> + <LINK REL="Index" HREF="index.html" > + <LINK REL="made" HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20Distrib-coffee%20big%20failure%20of%20the%20century&In-Reply-To=%3C509308A7.6030605%40zen.co.uk%3E"> + <META NAME="robots" CONTENT="index,nofollow"> + <META http-equiv="Content-Type" content="text/html; charset=us-ascii"> + <LINK REL="Previous" HREF="019732.html"> + <LINK REL="Next" HREF="019782.html"> + </HEAD> + <BODY BGCOLOR="#ffffff"> + <H1>[Mageia-dev] Distrib-coffee big failure of the century</H1> + <B>Barry Jackson</B> + <A HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20Distrib-coffee%20big%20failure%20of%20the%20century&In-Reply-To=%3C509308A7.6030605%40zen.co.uk%3E" + TITLE="[Mageia-dev] Distrib-coffee big failure of the century">zen25000 at zen.co.uk + </A><BR> + <I>Fri Nov 2 00:41:27 CET 2012</I> + <P><UL> + <LI>Previous message: <A HREF="019732.html">[Mageia-dev] Distrib-coffee big failure of the century +</A></li> + <LI>Next message: <A HREF="019782.html">[Mageia-dev] Barry's cronsync script - Bugs +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#19735">[ date ]</a> + <a href="thread.html#19735">[ thread ]</a> + <a href="subject.html#19735">[ subject ]</a> + <a href="author.html#19735">[ author ]</a> + </LI> + </UL> + <HR> +<!--beginarticle--> +<PRE>On 01/11/12 20:51, Barry Jackson wrote: +><i> +</I>><i> See how it goes :) +</I>><i> +</I>Last update - honest - added proper file lock as the existing method was +flakey - it's finished and I'm leaving it alone now :) +Attached and also here:- +<A HREF="http://paste.kde.org/588158/12522135/">http://paste.kde.org/588158/12522135/</A> + +-------------- next part -------------- +#!/bin/bash +# ~/cronsync by barjac +# Run with e.g. crontab:- 30 * * * * $HOME/cronsync +# Set using crontab -e +################### +# List of mirrors in preference order to use:- +mymirrors=( \ +"<A HREF="rsync://distrib-coffee.ipsl.jussieu.fr:/pub/linux/Mageia/distrib">rsync://distrib-coffee.ipsl.jussieu.fr:/pub/linux/Mageia/distrib</A>" \ +"<A HREF="rsync://ftp.LinuxCabal.org/Mageia/distrib">rsync://ftp.LinuxCabal.org/Mageia/distrib</A>" \ +"<A HREF="rsync://fr2.rpmfind.net/linux/mageia/distrib">rsync://fr2.rpmfind.net/linux/mageia/distrib</A>" \ +"<A HREF="rsync://ftp.acc.umu.se/mirror/mageia/distrib">rsync://ftp.acc.umu.se/mirror/mageia/distrib</A>" \ +"<A HREF="rsync://mirrors.kernel.org:/mirrors/mageia/distrib">rsync://mirrors.kernel.org:/mirrors/mageia/distrib</A>" \ +"<A HREF="rsync://mageia.c3sl.ufpr.br/mageia/distrib">rsync://mageia.c3sl.ufpr.br/mageia/distrib</A>" \ +) +# Set limit for loss of # of files on server before it is skipped +allowdropfiles=100 +################### +# Personal config:- +myexcludes="--exclude=debug --exclude=SRPMS --exclude=barjac" +mydestination="/zmrepo/pub/linux/Mageia/" +################### + +# Set minimum files for first run only +[[ -f .cronsync ]] || echo "140000" > $HOME/.cronsync +# Get minimum file count for mirror (set at allowdropfiles files less than the last actual file count) +minfiles=$(cat .cronsync) +((actualfiles = $minfiles + $allowdropfiles)) + +# Function to output formatted date +dte() +{ +echo -n $(date +%d/%m/%Y-%H:%M) +} + +# Check a mirror +chk_mirror() +{ +echo "Checking $1 ..." +rsync -rlptgoDhHSn \ +--stats \ +--delete-after \ +--delete-excluded \ +--protect-args \ +$myexcludes \ +"$1" \ +"$mydestination" > $lockdir/cronsync_tmp_output +status=$? +files=$(cat $lockdir/cronsync_tmp_output | grep "Number of files:" | cut -d' ' -f4 ) +[[ $files -lt $minfiles ]] && echo "$(dte): Only $files/$actualfiles files in $1" | tee -a $HOME/cronsync_error.log +[[ $status > 0 ]] && echo "$(dte): Error: $status while checking $1" | tee -a $HOME/cronsync_error.log +([[ $status = 0 ]] && [[ $files -gt $minfiles ]]) || return 1 +# Save new minimum file count +((minfiles = $files - $allowdropfiles)) +echo $minfiles > $HOME/.cronsync +return 0 +} + +# Loop through mirror list checking until one succeeds +find_good_mirror() +{ +for mirr in ${mymirrors[@]}; do +chk_mirror $mirr && { echo "Found good mirror - $mirr"; return 0; } +done +echo "$(dte): Can't find a good mirror - aborting" | tee -a $HOME/cronsync_error.log +return 1 +} +################### Main routine starts here +# Avoid running two instances concurrently +lockdir=/tmp/cronsync.lock +if mkdir "$lockdir"; then +trap 'rm -rf "$lockdir"' 0 + +# Find a good mirror from the list (with files in it) +find_good_mirror || exit 1 + +# Live run with --max-delete set to 1000 just in case ;) +echo "Syncing from $mirr ..." +rsync -rlptgoDhHS \ +--progress \ +--stats \ +--delete-after \ +--max-delete=1000 \ +--delete-excluded \ +--protect-args \ +$myexcludes \ +"$mirr" \ +"$mydestination" | tee $HOME/cronsync_last.log +status=${PIPESTATUS[0]} +[[ $status = 0 ]] || { echo "$(dte): Live run rsync error: $status" >> $HOME/cronsync_error.log; exit 1; } +echo "Update complete" +else +echo "$(dte): cronsync already running or stale lock - skipping update - check /tmp/cronsync.lock" >> $HOME/cronsync_error.log +exit 0 +fi +################### End of cronsync + + + + + +</PRE> + + +<!--endarticle--> + <HR> + <P><UL> + <!--threads--> + <LI>Previous message: <A HREF="019732.html">[Mageia-dev] Distrib-coffee big failure of the century +</A></li> + <LI>Next message: <A HREF="019782.html">[Mageia-dev] Barry's cronsync script - Bugs +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#19735">[ date ]</a> + <a href="thread.html#19735">[ thread ]</a> + <a href="subject.html#19735">[ subject ]</a> + <a href="author.html#19735">[ author ]</a> + </LI> + </UL> + +<hr> +<a href="https://www.mageia.org/mailman/listinfo/mageia-dev">More information about the Mageia-dev +mailing list</a><br> +</body></html> |