From e73b6ff49fdbc90d6b5617bb66260cfdce6f46d6918f4bed004aa7a63294fdab Mon Sep 17 00:00:00 2001 From: Till Wegmueller Date: Sun, 26 Oct 2025 22:09:37 +0100 Subject: [PATCH] Refactor Solstice bootstrapping logic into standalone script This commit replaces inline workflow preparation logic with a dedicated `solstice-bootstrap.sh` script, simplifying workspace setup, job execution, and shutdown processes. The change ensures cleaner orchestration and improves maintainability by centralizing the bootstrapping logic. --- crates/orchestrator/src/main.rs | 34 +++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/crates/orchestrator/src/main.rs b/crates/orchestrator/src/main.rs index 1f0eba5..5325e5c 100644 --- a/crates/orchestrator/src/main.rs +++ b/crates/orchestrator/src/main.rs @@ -221,11 +221,37 @@ write_files: content: | repo_url: {repo} commit_sha: {sha} + - path: /usr/local/bin/solstice-bootstrap.sh + permissions: '0755' + owner: root:root + content: | + #!/bin/sh + set -eu + echo "Solstice: bootstrapping workflow runner for {sha}" | tee /dev/console + RUNNER="/usr/local/bin/solstice-runner" + if [ ! -x "$RUNNER" ]; then + mkdir -p /usr/local/bin + if command -v curl >/dev/null 2>&1 && [ -n "$SOLSTICE_RUNNER_URL" ]; then + curl -fSL "$SOLSTICE_RUNNER_URL" -o "$RUNNER" || true + elif command -v wget >/dev/null 2>&1 && [ -n "$SOLSTICE_RUNNER_URL" ]; then + wget -O "$RUNNER" "$SOLSTICE_RUNNER_URL" || true + else + echo 'runner URL not provided or curl/wget missing' | tee /dev/console + fi + chmod +x "$RUNNER" 2>/dev/null || true + fi + export SOLSTICE_REPO_URL='{repo}' + export SOLSTICE_COMMIT_SHA='{sha}' + export SOLSTICE_JOB_FILE='/etc/solstice/job.yaml' + if [ -x "$RUNNER" ]; then + "$RUNNER" || true + else + echo 'solstice-runner not found; nothing to execute' | tee /dev/console + fi + echo 'Solstice: runner complete, powering off' | tee /dev/console + (command -v poweroff >/dev/null 2>&1 && poweroff) || (command -v shutdown >/dev/null 2>&1 && shutdown -y -i5 -g0) || true runcmd: - - [ sh, -c, "echo 'Solstice: preparing workspace for {sha}' | tee /dev/console" ] - - [ sh, -c, "mkdir -p /root/work && cd /root/work && if command -v git >/dev/null 2>&1; then git init && git remote add origin {repo} && git fetch --depth=1 origin {sha} && git checkout -q FETCH_HEAD || true; else echo 'git not installed'; fi" ] - - [ sh, -c, "if [ -f /root/work/.solstice/job.sh ]; then chmod +x /root/work/.solstice/job.sh && cd /root/work && /root/work/.solstice/job.sh || true; else echo 'No .solstice/job.sh found in repo'; fi" ] - - [ sh, -c, "echo 'Solstice: job complete, powering off' | tee /dev/console; (command -v poweroff >/dev/null 2>&1 && poweroff) || (command -v shutdown >/dev/null 2>&1 && shutdown -y -i5 -g0) || true" ] + - [ /usr/local/bin/solstice-bootstrap.sh ] "#, repo = repo_url, sha = commit_sha); s.into_bytes() }