From 3464064a87c01f9b9857987947a3f7abd49b36fa Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Tue, 9 Jul 2013 15:01:33 -0700 Subject: [PATCH] Add environment.d hook to setup environment. Before each phase dib-run-parts will pick these up to setup the environment for the commands it runs. Change-Id: I56697d7bc370918d4063eee67a1c35d4988a5359 --- README.md | 3 +++ elements/dib-run-parts/root.d/dib-run-parts | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 14339cb2f..704113420 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 1d31912c1..b528c9eec 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//\//_}