From f82863941f2a2835898dbb7bc47d27c2e783b744 Mon Sep 17 00:00:00 2001 From: Malfurious Date: Wed, 9 Aug 2023 06:31:14 -0400 Subject: acid: Add entrypoint script Signed-off-by: Malfurious --- acid/cychedelic | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 acid/cychedelic diff --git a/acid/cychedelic b/acid/cychedelic new file mode 100755 index 0000000..002fb98 --- /dev/null +++ b/acid/cychedelic @@ -0,0 +1,52 @@ +#!/bin/bash + +# cychedelic ACID daemon +# cychedelic is an automated Continuous Deployment solution. See the README for +# more information. + +source config.sh + +now() { + date '+%s' +} + +should_restart() { + curtime=$(now) + runtime=$((curtime-starttime)) + [ $runtime -gt $CYCHE_MAINT_TIME ] +} + +update() { + forceopt="--force-self" + selfopt="--self" + + for line in "${CYCHE_SERVICES[@]}"; do + hash=$(cyche-source $line) + + if [ $? -ne 0 ] || [ "$1" == "$forceopt" ]; then + read -r -a arr <<< "$line" + cyche-build "${arr[0]}" "$hash" $selfopt + fi + + forceopt="--force" + selfopt="" + done +} + +# startup: A restart of the ACID daemon usually indicates an elapse of the +# $CYCHE_MAINT_TIME period, so rebuild services and perform cleanup now. We +# sleep briefly at the beginning to allow the previous cychedelic instance time +# to die. +sleep "$CYCHE_STARTUP_TIME" +update --force +docker system prune --force --all +starttime=$(now) + +# monitor source changes +while ! should_restart; do + sleep "$CYCHE_POLL_TIME" + update +done + +# force self-upgrade to trigger maintenance activities +update --force-self -- cgit v1.2.3