1 |
commit: bb1e9c6759e26204ae137589adbc1c048afc7f3c |
2 |
Author: Theo Chatzimichos <tampakrap <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Dec 26 14:01:29 2012 +0000 |
4 |
Commit: Theo Chatzimichos <tampakrap <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Dec 26 14:01:29 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-mirrorstats.git;a=commit;h=bb1e9c67 |
7 |
|
8 |
Add documentation and fix whitespace in mirror-validate script |
9 |
Also adjust it with the upcoming |
10 |
{source,portage}_mirrors->{distfiles,rsync}_mirrors move |
11 |
|
12 |
--- |
13 |
validation/mirror-validate.sh | 59 +++++++++++++++++++++------------------- |
14 |
1 files changed, 31 insertions(+), 28 deletions(-) |
15 |
|
16 |
diff --git a/validation/mirror-validate.sh b/validation/mirror-validate.sh |
17 |
index bd63d17..e5348ec 100755 |
18 |
--- a/validation/mirror-validate.sh |
19 |
+++ b/validation/mirror-validate.sh |
20 |
@@ -1,41 +1,44 @@ |
21 |
#!/bin/bash |
22 |
+# Check if the mirror is alive and not lagging. |
23 |
+# The script performs three checks, and it proceeds only when the check fails: |
24 |
+# 1) Check if the mirror is fully clean, else proceed |
25 |
+# 2) Check if the latest attempts where clean (five for distfiles, one for |
26 |
+# rsync), else proceed |
27 |
+# 3) Check if it had more than 10 failed attempts. If it does, then print |
28 |
+# the mirror, else skip |
29 |
|
30 |
. /etc/init.d/functions.sh |
31 |
|
32 |
-if [[ $1 == "distfiles" ]]; then |
33 |
- MIRMON_PATH="source" |
34 |
-elif [[ $1 == "rsync" ]]; then |
35 |
- MIRMON_PATH="portage" |
36 |
-else |
37 |
- echo "Need to specify distfiles or rsync" |
38 |
- exit 1 |
39 |
+if [[ $1 != "distfiles" ]] && [[ $1 != "rsync" ]]; then |
40 |
+ echo "Need to specify distfiles or rsync" |
41 |
+ exit 1 |
42 |
fi |
43 |
|
44 |
-STATE_FILE="/var/www/mirrorstats.gentoo.org/gentoo-mirrorstats/${MIRMON_PATH}_mirrors/var/mirmon.state" |
45 |
+STATE_FILE="/var/www/mirrorstats.gentoo.org/gentoo-mirrorstats/$1_mirrors/var/mirmon.state" |
46 |
|
47 |
count_bad_status() { |
48 |
- BAD_STATUS_COUNT=0 |
49 |
- i=0 |
50 |
- while (( i++ < ${#FULL_STATUS} )); do |
51 |
- echo $(expr substr "$FULL_STATUS" $i 1) | grep -v -q s && \ |
52 |
- BAD_STATUS_COUNT=$((BAD_STATUS_COUNT + 1)) |
53 |
- done |
54 |
- [ $BAD_STATUS_COUNT -ge 10 ] && echo $NAME |
55 |
+ BAD_STATUS_COUNT=0 |
56 |
+ i=0 |
57 |
+ while (( i++ < ${#FULL_STATUS} )); do |
58 |
+ echo $(expr substr "$FULL_STATUS" $i 1) | grep -v -q s && \ |
59 |
+ BAD_STATUS_COUNT=$((BAD_STATUS_COUNT + 1)) |
60 |
+ done |
61 |
+ [ $BAD_STATUS_COUNT -ge 10 ] && echo $NAME |
62 |
} |
63 |
|
64 |
while read mirror; do |
65 |
- NAME=`echo $mirror | cut -d' ' -f1` |
66 |
+ NAME=`echo $mirror | cut -d' ' -f1` |
67 |
FULL_STATUS=`echo $mirror | cut -d' ' -f6 | cut -d'-' -f2` |
68 |
- if [[ $1 == "distfiles" ]]; then |
69 |
- LATEST_STATUS="${FULL_STATUS:9:5}" |
70 |
- LATEST_STATUS_EXP="sssss" |
71 |
- elif [[ $1 == "rsync" ]]; then |
72 |
- LATEST_STATUS="${FULL_STATUS:13:1}" |
73 |
- LATEST_STATUS_EXP="s" |
74 |
- fi |
75 |
- if [[ $FULL_STATUS != "ssssssssssssss" ]]; then |
76 |
- if [[ $LATEST_STATUS != $LATEST_STATUS_EXP ]]; then |
77 |
- count_bad_status |
78 |
- fi |
79 |
- fi |
80 |
+ if [[ $1 == "distfiles" ]]; then |
81 |
+ LATEST_STATUS="${FULL_STATUS:9:5}" |
82 |
+ LATEST_STATUS_EXP="sssss" |
83 |
+ elif [[ $1 == "rsync" ]]; then |
84 |
+ LATEST_STATUS="${FULL_STATUS:13:1}" |
85 |
+ LATEST_STATUS_EXP="s" |
86 |
+ fi |
87 |
+ if [[ $FULL_STATUS != "ssssssssssssss" ]]; then |
88 |
+ if [[ $LATEST_STATUS != $LATEST_STATUS_EXP ]]; then |
89 |
+ count_bad_status |
90 |
+ fi |
91 |
+ fi |
92 |
done < $STATE_FILE |