blob: e845aa71e7ac945dffa9fa321a1504c7a44d027b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# cloud-run-user-script - runs user scripts found in user-data, that are
# stored in /var/lib/cloud/scripts by the initial cloudinit upstart job
description "execute cloud user scripts"
start on (stopped rc RUNLEVEL=[2345] and stopped cloud-config)
console output
task
script
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
|