commit: e0efc96938fdb5b8af7b67cac892dc630fa4d3d5
Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 7 20:49:03 2023 +0000
Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Mon Aug 7 20:49:03 2023 +0000
URL: https://gitweb.gentoo.org/proj/binhost.git/commit/?id=e0efc969
Improve the main runner somewhat
Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>
builders/demeter/binhost-update | 39 ++++++++++++++++++++++++++++++---------
1 file changed, 30 insertions(+), 9 deletions(-)
diff --git a/builders/demeter/binhost-update b/builders/demeter/binhost-update
index b758cb5..b9c2892 100755
--- a/builders/demeter/binhost-update
+++ b/builders/demeter/binhost-update
@@ -1,12 +1,18 @@
#!/bin/bash
-BINHOST_NAME=amd64-default-17.1
+BINHOST_NAME=amd64/17.1/x86-64
+_BINHOST_NAME=$(echo ${BINHOST_NAME}|sed -e 's:/:_:g')
-TMPFILE="/root/.tmp-binhost-${BINHOST_NAME}-update-$(date +%s)"
+TMPFILE="/root/.tmp-binhost-${_BINHOST_NAME}-update-$(date +%s)"
+LOCKFILE="/root/.tmp-binhost-${_BINHOST_NAME}-lock"
[email protected]
[email protected]
+NSPAWN_NAMES="binhost-amd64-x86-64 binhost-amd64-x86-64-gnome"
+
+MAX_HARMLESS=10
+
send_email() {
local subject="[binhost ${BINHOST_NAME}] $1"
local message=$2
@@ -26,15 +32,30 @@ send_email() {
-if
- systemd-nspawn -M binhost-amd64-x86-64 /root/bin/run-update &> ${TMPFILE} &&
- systemd-nspawn -M binhost-amd64-x86-64-gnome /root/bin/run-update &>>
${TMPFILE} ; then
+if [[ -f ${LOCKFILE} ]] ; then
+ echo "lockfile ${LOCKFILE} exists, aborting"
+ exit 111
+fi
+touch ${LOCKFILE} || exit 112
+
+
+echo Starting run at $(date -u) > ${TMPFILE}
+
+for n in ${NSPAWN_NAMES} ; do
+ echo Machine ${n} &>> ${TMPFILE}
+ echo &>> ${TMPFILE}
+ cd /var/lib/machines/${n}/root/binhost &>> ${TMPFILE}
+ git pull -q &>> ${TMPFILE}
+ cd /root &>> ${TMPFILE}
+ systemd-nspawn -M ${n} /root/bin/run-update &>> ${TMPFILE}
+done
- send_email "Update succeeded" "Binhost ${BINHOST_NAME} update succeeded"
${TMPFILE}
- rm ${TMPFILE}
-else
+if [[ $(wc -l ${TMPFILE} | sed -e 's: .*$::g') -gt ${MAX_HARMLESS} ]] ; then
- send_email "Update failed" "Binhost ${BINHOST_NAME} update failed" ${TMPFILE}
+ send_email "Update possibly failed" "Binhost ${BINHOST_NAME} update produced
long output" ${TMPFILE}
fi
+
+
+rm ${LOCKFILE}