From 94fe55e8190fadaa4094d83cef2e7d73167ab793 Mon Sep 17 00:00:00 2001 From: Josh Palmer Date: Wed, 4 Feb 2026 06:31:17 -0800 Subject: [PATCH] infra: force oneshot rerun - restart bootstrap/repo-seed to honor new prefix - wait for new ExecMainStartTimestamp --- infra/opentofu/aws/user-data.sh.tmpl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/infra/opentofu/aws/user-data.sh.tmpl b/infra/opentofu/aws/user-data.sh.tmpl index 1050052..c1a1894 100644 --- a/infra/opentofu/aws/user-data.sh.tmpl +++ b/infra/opentofu/aws/user-data.sh.tmpl @@ -23,21 +23,23 @@ wait_for_service() { local state local result local start_ts + local previous_start_ts if [ "$#" -ge 2 ]; then timeout="$2" fi - systemctl start "$service" + previous_start_ts="$(systemctl show -p ExecMainStartTimestampMonotonic --value "$service")" + systemctl restart "$service" while true; do state="$(systemctl show -p ActiveState --value "$service")" result="$(systemctl show -p Result --value "$service")" start_ts="$(systemctl show -p ExecMainStartTimestampMonotonic --value "$service")" - if [ "$state" = "active" ]; then + if [ "$state" = "active" ] && [ "$start_ts" != "$previous_start_ts" ]; then return 0 fi - if [ "$state" = "inactive" ] && [ "$result" = "success" ] && [ "$start_ts" != "0" ]; then + if [ "$state" = "inactive" ] && [ "$result" = "success" ] && [ "$start_ts" != "0" ] && [ "$start_ts" != "$previous_start_ts" ]; then return 0 fi if [ "$state" = "failed" ] || [ "$result" = "exit-code" ] || [ "$result" = "timeout" ] || [ "$result" = "failed" ]; then