diff options
author | 2012-12-26 15:01:29 +0100 | |
---|---|---|
committer | 2012-12-26 15:01:29 +0100 | |
commit | bb1e9c6759e26204ae137589adbc1c048afc7f3c (patch) | |
tree | 791d438c3ff2900752eff093d1ce79c052ae136d | |
parent | Add script to catch bad mirrors (diff) | |
download | gentoo-mirrorstats-bb1e9c6759e26204ae137589adbc1c048afc7f3c.tar.gz gentoo-mirrorstats-bb1e9c6759e26204ae137589adbc1c048afc7f3c.tar.bz2 gentoo-mirrorstats-bb1e9c6759e26204ae137589adbc1c048afc7f3c.zip |
Add documentation and fix whitespace in mirror-validate script
Also adjust it with the upcoming
{source,portage}_mirrors->{distfiles,rsync}_mirrors move
-rwxr-xr-x | validation/mirror-validate.sh | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/validation/mirror-validate.sh b/validation/mirror-validate.sh index bd63d17..e5348ec 100755 --- a/validation/mirror-validate.sh +++ b/validation/mirror-validate.sh @@ -1,41 +1,44 @@ #!/bin/bash +# Check if the mirror is alive and not lagging. +# The script performs three checks, and it proceeds only when the check fails: +# 1) Check if the mirror is fully clean, else proceed +# 2) Check if the latest attempts where clean (five for distfiles, one for +# rsync), else proceed +# 3) Check if it had more than 10 failed attempts. If it does, then print +# the mirror, else skip . /etc/init.d/functions.sh -if [[ $1 == "distfiles" ]]; then - MIRMON_PATH="source" -elif [[ $1 == "rsync" ]]; then - MIRMON_PATH="portage" -else - echo "Need to specify distfiles or rsync" - exit 1 +if [[ $1 != "distfiles" ]] && [[ $1 != "rsync" ]]; then + echo "Need to specify distfiles or rsync" + exit 1 fi -STATE_FILE="/var/www/mirrorstats.gentoo.org/gentoo-mirrorstats/${MIRMON_PATH}_mirrors/var/mirmon.state" +STATE_FILE="/var/www/mirrorstats.gentoo.org/gentoo-mirrorstats/$1_mirrors/var/mirmon.state" count_bad_status() { - BAD_STATUS_COUNT=0 - i=0 - while (( i++ < ${#FULL_STATUS} )); do - echo $(expr substr "$FULL_STATUS" $i 1) | grep -v -q s && \ - BAD_STATUS_COUNT=$((BAD_STATUS_COUNT + 1)) - done - [ $BAD_STATUS_COUNT -ge 10 ] && echo $NAME + BAD_STATUS_COUNT=0 + i=0 + while (( i++ < ${#FULL_STATUS} )); do + echo $(expr substr "$FULL_STATUS" $i 1) | grep -v -q s && \ + BAD_STATUS_COUNT=$((BAD_STATUS_COUNT + 1)) + done + [ $BAD_STATUS_COUNT -ge 10 ] && echo $NAME } while read mirror; do - NAME=`echo $mirror | cut -d' ' -f1` + NAME=`echo $mirror | cut -d' ' -f1` FULL_STATUS=`echo $mirror | cut -d' ' -f6 | cut -d'-' -f2` - if [[ $1 == "distfiles" ]]; then - LATEST_STATUS="${FULL_STATUS:9:5}" - LATEST_STATUS_EXP="sssss" - elif [[ $1 == "rsync" ]]; then - LATEST_STATUS="${FULL_STATUS:13:1}" - LATEST_STATUS_EXP="s" - fi - if [[ $FULL_STATUS != "ssssssssssssss" ]]; then - if [[ $LATEST_STATUS != $LATEST_STATUS_EXP ]]; then - count_bad_status - fi - fi + if [[ $1 == "distfiles" ]]; then + LATEST_STATUS="${FULL_STATUS:9:5}" + LATEST_STATUS_EXP="sssss" + elif [[ $1 == "rsync" ]]; then + LATEST_STATUS="${FULL_STATUS:13:1}" + LATEST_STATUS_EXP="s" + fi + if [[ $FULL_STATUS != "ssssssssssssss" ]]; then + if [[ $LATEST_STATUS != $LATEST_STATUS_EXP ]]; then + count_bad_status + fi + fi done < $STATE_FILE |