From be61755c7723790b68f30b8acaf1ce8ba2410dd4 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Mon, 24 Jan 2011 11:58:11 -0500 Subject: fix cloud-run-user-script for directory change, make it invoke other scripts Now, in addition to running instance specific scripts (in runcmd or user-data scripts), cloud-run-user-script will run other directories also. All under /var/lib/cloud, and in the following order: scripts/per-once [once ever] scripts/per-boot [every boot] scripts/per-instance [once per instance] instance/scripts [once per instance] At the moment, the marker is on the entire directory, so changes to that directory. Changes to the contents of the directory will not be noticed. --- upstart/cloud-run-user-script.conf | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'upstart') diff --git a/upstart/cloud-run-user-script.conf b/upstart/cloud-run-user-script.conf index 9a47e57b..e845aa71 100644 --- a/upstart/cloud-run-user-script.conf +++ b/upstart/cloud-run-user-script.conf @@ -7,10 +7,22 @@ console output task script -iid=$(cloud-init-query instance-id) || exit 1 -sdir="/var/lib/cloud/data/scripts/${iid}" -if [ -d "$sdir" ]; then - exec cloud-init-run-module once-per-instance user-scripts execute \ - run-parts --regex '.*' "$sdir" -fi +bd=/var/lib/cloud +toks=" + ${bd}/scripts/per-once:once:cloud-scripts-per-once + ${bd}/scripts/per-boot:always:cloud-scripts-per-boot + ${bd}/scripts/per-instance:once-per-instance:cloud-scripts-per-instance + ${bd}/instance/scripts:once-per-instance:user-scripts +" +oifs=${IFS} +errors="" +for tok in ${toks}; do + IFS=":"; set -- ${tok}; IFS=${oifs} + dir=${1}; per=${2}; name=${3} + [ -d "${dir}" ] || continue + cloud-init-run-module "${per}" "${name}" execute \ + run-parts --regex '.*' "$dir" || errors="${errors} ${name}" +done +errors=${errors# } +[ -z "${errors}" ] || { echo "errors executing ${errors}" 1>&2; exit 1; } end script -- cgit v1.2.3