Skip to content

Commit a52cb63

Browse files
Pangjipingclaude
andauthored
Feat/execd bootstrap pre script (#901)
* feat(execd): support user-defined pre-script in bootstrap Add `BOOTSTRAP_PRE_SCRIPT` env to declare a script that runs before execd starts. The script is sourced (POSIX `.`) rather than executed so any variables it `export`s propagate to execd and the chained command — a subprocess would lose those exports on exit. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * refactor(execd): rename BOOTSTRAP_PRE_SCRIPT to EXECD_BOOTSTRAP_PRE_SCRIPT Prefix with the component name to keep the env namespace consistent with other execd-scoped variables (`EXECD`, `EXECD_ENVS`). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent c1d19b7 commit a52cb63

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

components/execd/bootstrap.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,27 @@ if ! touch "$EXECD_ENVS" 2>/dev/null; then
172172
fi
173173
export EXECD_ENVS
174174

175+
# Run a user-defined pre-script before launching execd. The script is sourced
176+
# with POSIX `.` (not executed as a child process) so any variables it
177+
# `export`s propagate to execd and the chained command below — a subprocess
178+
# would lose those exports the moment it exits.
179+
if [ -n "${EXECD_BOOTSTRAP_PRE_SCRIPT:-}" ]; then
180+
if [ -f "$EXECD_BOOTSTRAP_PRE_SCRIPT" ] && [ -r "$EXECD_BOOTSTRAP_PRE_SCRIPT" ]; then
181+
# Force `.` to read the literal path; without a slash it would fall
182+
# back to a PATH search and could load the wrong file.
183+
case "$EXECD_BOOTSTRAP_PRE_SCRIPT" in
184+
*/*) _pre_script="$EXECD_BOOTSTRAP_PRE_SCRIPT" ;;
185+
*) _pre_script="./$EXECD_BOOTSTRAP_PRE_SCRIPT" ;;
186+
esac
187+
echo "sourcing pre-script $EXECD_BOOTSTRAP_PRE_SCRIPT"
188+
# shellcheck disable=SC1090
189+
. "$_pre_script"
190+
unset _pre_script
191+
else
192+
echo "warning: EXECD_BOOTSTRAP_PRE_SCRIPT=$EXECD_BOOTSTRAP_PRE_SCRIPT not found or not readable" >&2
193+
fi
194+
fi
195+
175196
echo "starting OpenSandbox Execd daemon at $EXECD."
176197
$EXECD &
177198

0 commit comments

Comments
 (0)