summaryrefslogtreecommitdiff
path: root/upstart
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2011-01-24 11:58:11 -0500
committerScott Moser <smoser@ubuntu.com>2011-01-24 11:58:11 -0500
commitbe61755c7723790b68f30b8acaf1ce8ba2410dd4 (patch)
treee8c95f25128d63ff3d8d4ffbe91ea24752138df5 /upstart
parent7e2e87f2de893835900eb5a96458a865f36c624c (diff)
downloadvyos-cloud-init-be61755c7723790b68f30b8acaf1ce8ba2410dd4.tar.gz
vyos-cloud-init-be61755c7723790b68f30b8acaf1ce8ba2410dd4.zip
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.
Diffstat (limited to 'upstart')
-rw-r--r--upstart/cloud-run-user-script.conf24
1 files changed, 18 insertions, 6 deletions
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