From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id B3383138350 for ; Tue, 28 Apr 2020 23:21:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D8783E0898; Tue, 28 Apr 2020 23:21:55 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C26DAE0898 for ; Tue, 28 Apr 2020 23:21:55 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7D1C034ECC1 for ; Tue, 28 Apr 2020 23:21:54 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 07D961C3 for ; Tue, 28 Apr 2020 23:21:53 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1588116081.97ea3377d7030d39b2f7340ebf060eb072ec2343.robbat2@gentoo> Subject: [gentoo-commits] proj/gentoo-mirrorstats:master commit in: / X-VCS-Repository: proj/gentoo-mirrorstats X-VCS-Files: mirmon-snapshots.sh X-VCS-Directories: / X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: 97ea3377d7030d39b2f7340ebf060eb072ec2343 X-VCS-Branch: master Date: Tue, 28 Apr 2020 23:21:53 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: ca5e3c62-8ddf-4b82-9140-0718fa2b260c X-Archives-Hash: c950ddef219dabb12ec0dcb74ecf5d1c commit: 97ea3377d7030d39b2f7340ebf060eb072ec2343 Author: Robin H. Johnson gentoo org> AuthorDate: Tue Apr 28 23:21:21 2020 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Tue Apr 28 23:21:21 2020 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-mirrorstats.git/commit/?id=97ea3377 mirmon-snapshots.sh: test refactor of runner Signed-off-by: Robin H. Johnson gentoo.org> mirmon-snapshots.sh | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/mirmon-snapshots.sh b/mirmon-snapshots.sh old mode 100644 new mode 100755 index 692a1ef..894e94b --- a/mirmon-snapshots.sh +++ b/mirmon-snapshots.sh @@ -1,18 +1,36 @@ #!/bin/bash -cd /var/www/mirrorstats.gentoo.org/gentoo-mirrorstats/snapshots_mirrors +set -e + +MODE=snapshots +SRC=distfiles +SITEDIR=/var/www/mirrorstats.gentoo.org +REPODIR=${SITEDIR}/gentoo-mirrorstats/ +MODEDIR=${SITEDIR}/${MODE}_mirrors/ +VARDIR=${SITEDIR}/var/${MODE} +HTDOCS=${SITEDIR}/htdocs/${MODE} +MIRMON=$(readlink -f "${SITEDIR}"/mirmon/mirmon) +CONFFILE=$(readlink -f "${MODEDIR}"/mirmon.conf) + # Grab mirrors from the web -[[ -d ./var ]] || mkdir ./var -../get-mirrors-from-distfiles-xml.rb > ./var/g.mirrors +mkdir -p "${VARDIR}" +"${REPODIR}"/get-mirrors-from-${SRC}-xml.rb > "${VARDIR}"/g.mirrors.tmp && mv -f "${VARDIR}"/g.mirrors{.tmp,} + # fatal if the state file is NOT present. -[[ -e ./var/mirmon.state ]] || touch ./var/mirmon.state +[[ -e ${VARDIR}/mirmon.state ]] || touch "${VARDIR}/mirmon.state" + # run mirmon -/usr/bin/perl ../../mirmon/mirmon -c ./mirmon.conf -q -get update +/usr/bin/perl "${MIRMON}" -c "${CONFFILE}" -q -get update + # Set up a nice link to our mirror page directly: -[[ -d ../../htdocs/snapshots ]] || mkdir ../../htdocs/snapshots +mkdir -p ${HTDOCS} sed \ -e 's#mirrors#mirrors#' \ - >../../htdocs/snapshots/index.html <../../htdocs/snapshots/index-wip.html + >"${HTDOCS}"/index.html.tmp <"${HTDOCS}"/index-wip.html \ + && mv -f "${HTDOCS}"/index.html{.tmp,} + # Generate a json file containing the state of each mirror -../json/generate-json.py /var/www/mirrorstats.gentoo.org/gentoo-mirrorstats/snapshots_mirrors/var/mirmon.state \ - > ../../htdocs/snapshots/state.json +../json/generate-json.py \ + "${VARDIR}"/mirmon.state \ + >"${HTDOCS}"/state.json.tmp \ + && mv -f "${HTDOCS}"/state.json{.tmp,}