diff --git a/README.md b/README.md index 14339cb2..70411342 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,9 @@ part of the process you need to customise: * first-boot.d: Runs inside the image before rc.local. Scripts from here are good for doing per-instance configuration based on cloud metadata. +* environment.d: Bash script snippets that are sourced before running scripts + in each phase. Use this to set an environment variable for other hooks. + * element-deps : A plain text, newline separated list of elements which will be added to the list of elements built into the image at image creation time. diff --git a/elements/dib-run-parts/root.d/dib-run-parts b/elements/dib-run-parts/root.d/dib-run-parts index 1d31912c..b528c9ee 100644 --- a/elements/dib-run-parts/root.d/dib-run-parts +++ b/elements/dib-run-parts/root.d/dib-run-parts @@ -49,6 +49,12 @@ targets=$(find $target_dir -type f -executable -printf '%f\n' | grep -E "$allowe PROFILE_DIR=$(mktemp -d /tmp/profiledir.XXXXXX) +if [ -d /tmp/in_target.d/environment.d ] ; then + for env_file in /tmp/in_target.d/environment.d/* ; do + source $env_file + done +fi + for target in $targets ; do output "Running $target_dir/$target" target_tag=${target//\//_}