Gentoo Archives: gentoo-commits

From: "Robin H. Johnson" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-mirrorstats:master commit in: /
Date: Tue, 28 Apr 2020 23:21:56
Message-Id: 1588116081.97ea3377d7030d39b2f7340ebf060eb072ec2343.robbat2@gentoo
1 commit: 97ea3377d7030d39b2f7340ebf060eb072ec2343
2 Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
3 AuthorDate: Tue Apr 28 23:21:21 2020 +0000
4 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
5 CommitDate: Tue Apr 28 23:21:21 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/gentoo-mirrorstats.git/commit/?id=97ea3377
7
8 mirmon-snapshots.sh: test refactor of runner
9
10 Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
11
12 mirmon-snapshots.sh | 36 +++++++++++++++++++++++++++---------
13 1 file changed, 27 insertions(+), 9 deletions(-)
14
15 diff --git a/mirmon-snapshots.sh b/mirmon-snapshots.sh
16 old mode 100644
17 new mode 100755
18 index 692a1ef..894e94b
19 --- a/mirmon-snapshots.sh
20 +++ b/mirmon-snapshots.sh
21 @@ -1,18 +1,36 @@
22 #!/bin/bash
23
24 -cd /var/www/mirrorstats.gentoo.org/gentoo-mirrorstats/snapshots_mirrors
25 +set -e
26 +
27 +MODE=snapshots
28 +SRC=distfiles
29 +SITEDIR=/var/www/mirrorstats.gentoo.org
30 +REPODIR=${SITEDIR}/gentoo-mirrorstats/
31 +MODEDIR=${SITEDIR}/${MODE}_mirrors/
32 +VARDIR=${SITEDIR}/var/${MODE}
33 +HTDOCS=${SITEDIR}/htdocs/${MODE}
34 +MIRMON=$(readlink -f "${SITEDIR}"/mirmon/mirmon)
35 +CONFFILE=$(readlink -f "${MODEDIR}"/mirmon.conf)
36 +
37 # Grab mirrors from the web
38 -[[ -d ./var ]] || mkdir ./var
39 -../get-mirrors-from-distfiles-xml.rb > ./var/g.mirrors
40 +mkdir -p "${VARDIR}"
41 +"${REPODIR}"/get-mirrors-from-${SRC}-xml.rb > "${VARDIR}"/g.mirrors.tmp && mv -f "${VARDIR}"/g.mirrors{.tmp,}
42 +
43 # fatal if the state file is NOT present.
44 -[[ -e ./var/mirmon.state ]] || touch ./var/mirmon.state
45 +[[ -e ${VARDIR}/mirmon.state ]] || touch "${VARDIR}/mirmon.state"
46 +
47 # run mirmon
48 -/usr/bin/perl ../../mirmon/mirmon -c ./mirmon.conf -q -get update
49 +/usr/bin/perl "${MIRMON}" -c "${CONFFILE}" -q -get update
50 +
51 # Set up a nice link to our mirror page directly:
52 -[[ -d ../../htdocs/snapshots ]] || mkdir ../../htdocs/snapshots
53 +mkdir -p ${HTDOCS}
54 sed \
55 -e 's#mirrors</H2>#<a href="http://www.gentoo.org/main/en/mirrors2.xml">mirrors</a></H2>#' \
56 - >../../htdocs/snapshots/index.html <../../htdocs/snapshots/index-wip.html
57 + >"${HTDOCS}"/index.html.tmp <"${HTDOCS}"/index-wip.html \
58 + && mv -f "${HTDOCS}"/index.html{.tmp,}
59 +
60 # Generate a json file containing the state of each mirror
61 -../json/generate-json.py /var/www/mirrorstats.gentoo.org/gentoo-mirrorstats/snapshots_mirrors/var/mirmon.state \
62 - > ../../htdocs/snapshots/state.json
63 +../json/generate-json.py \
64 + "${VARDIR}"/mirmon.state \
65 + >"${HTDOCS}"/state.json.tmp \
66 + && mv -f "${HTDOCS}"/state.json{.tmp,}