prefix all variables with __cdist
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
1d796e6ed1
commit
db1b7eac6c
1 changed files with 37 additions and 37 deletions
|
@ -34,75 +34,75 @@ set -eu
|
|||
__cdist_target_host="$1"; shift
|
||||
__cdist_object_base_dir="$1"; shift
|
||||
|
||||
objectlist="${__cdist_tmp_dir}/objectfile"
|
||||
newobjectlist="${__cdist_tmp_dir}/newobjectfile"
|
||||
newobjects="${__cdist_tmp_dir}/newobjects"
|
||||
__cdist_objects_list="${__cdist_tmp_dir}/objects_file"
|
||||
__cdist_new_objects_list="${__cdist_tmp_dir}/new_objects_file"
|
||||
__cdist_new_objects_dir="${__cdist_tmp_dir}/new_objects_dir"
|
||||
|
||||
new_objects_created=y
|
||||
__cdist_new_objects_created=y
|
||||
|
||||
# Loop until we do not create new objects anymore
|
||||
# which is equal to all objects have been run
|
||||
while [ "$new_objects_created" = "y" ]; do
|
||||
while [ "$__cdist_new_objects_created" = "y" ]; do
|
||||
# assume we're done after this run
|
||||
new_objects_created=n
|
||||
__cdist_new_objects_created=n
|
||||
|
||||
# find all objects (every object has the source recorded)
|
||||
__cdist_object_list "$__cdist_object_base_dir" > "$objectlist"
|
||||
__cdist_object_list "$__cdist_object_base_dir" > "$__cdist_objects_list"
|
||||
|
||||
# Check every object, if we need to run it
|
||||
while read object; do
|
||||
cur_object_dir="$__cdist_object_base_dir/$object"
|
||||
while read __cdist_object; do
|
||||
__cdist_cur_object_dir="$__cdist_object_base_dir/$__cdist_object"
|
||||
|
||||
if [ ! -f "${cur_object_dir}/$__cdist_name_object_finished" ]; then
|
||||
echo "Working on object ${object} ..."
|
||||
if [ ! -f "${__cdist_cur_object_dir}/$__cdist_name_object_finished" ]; then
|
||||
echo "Working on object ${__cdist_object} ..."
|
||||
|
||||
type="${object%%/*}"
|
||||
manifest="$__cdist_type_dir/${type}/${__cdist_name_manifest}"
|
||||
echo $manifest
|
||||
__cdist_type="${__cdist_object%%/*}"
|
||||
__cdist_manifest="$__cdist_type_dir/${__cdist_type}/${__cdist_name_manifest}"
|
||||
echo $__cdist_manifest
|
||||
|
||||
if [ -x "${manifest}" ]; then
|
||||
echo "Executing manifest ${manifest} ..."
|
||||
cdist-manifest-run "$__cdist_target_host" "${manifest}" "${newobjects}"
|
||||
__cdist_object_list "${newobjects}" > "$newobjectlist"
|
||||
if [ -x "${__cdist_manifest}" ]; then
|
||||
echo "Executing manifest ${__cdist_manifest} ..."
|
||||
cdist-manifest-run "$__cdist_target_host" "${__cdist_manifest}" "${__cdist_new_objects_dir}"
|
||||
__cdist_object_list "${__cdist_new_objects_dir}" > "$__cdist_new_objects_list"
|
||||
|
||||
# Verify no conflicting objects have been created
|
||||
while read newobject; do
|
||||
grep -q "^$newobject\$" "$objectlist" && \
|
||||
__cdist_exit_err "${manifest} tried to recreate ${newobject}"
|
||||
done < "$newobjectlist"
|
||||
while read __cdist_new_object; do
|
||||
grep -q "^$__cdist_new_object\$" "$__cdist_objects_list" && \
|
||||
__cdist_exit_err "${__cdist_manifest}: Tried to recreate ${__cdist_new_object}"
|
||||
done < "$__cdist_new_objects_list"
|
||||
|
||||
# Safe harbour: We can merge all objects into main tree
|
||||
# Merge = mkdir + mv parameters and source information
|
||||
while read newobject; do
|
||||
[ "$new_objects_created" = "n" ] && new_objects_created="y"
|
||||
while read __cdist_new_object; do
|
||||
[ "$__cdist_new_objects_created" = "n" ] && __cdist_new_objects_created="y"
|
||||
|
||||
set -x
|
||||
# where to save the newly created object
|
||||
object_dir="$__cdist_object_base_dir/$newobject"
|
||||
__cdist_object_dir="$__cdist_object_base_dir/$__cdist_new_object"
|
||||
|
||||
# Source of the new object
|
||||
new_object_dir="${newobjects}/$newobject"
|
||||
__cdist_new_object_dir="${__cdist_new_objects_dir}/$__cdist_new_object"
|
||||
|
||||
find $new_object_dir
|
||||
find $__cdist_new_object_dir
|
||||
|
||||
mkdir -p "$object_dir"
|
||||
mkdir -p "$__cdist_object_dir"
|
||||
# Move parameters and source information
|
||||
mv "${new_object_dir}/"* "$object_dir"
|
||||
mv "${new_object_dir}/${__cdist_name_object_source}" "$object_dir"
|
||||
mv "${__cdist_new_object_dir}/"* "$__cdist_object_dir"
|
||||
mv "${__cdist_new_object_dir}/${__cdist_name_object_source}" "$__cdist_object_dir"
|
||||
set +x
|
||||
done < "$newobjectlist"
|
||||
done < "$__cdist_new_objects_list"
|
||||
|
||||
# Remove listing and rest of newobjects, otherwise the next type will reuse it...
|
||||
rm -rf "$newobjects" "$newobjectlist"
|
||||
# Remove listing and objects, otherwise the next type will reuse it...
|
||||
rm -rf "$__cdist_new_objects_dir" "$__cdist_new_objects_list"
|
||||
else
|
||||
# Be nice, warn user if manifests exists, but is not executable
|
||||
if [ -f "${manifest}" ]; then
|
||||
echo "Warning ${manifest} exists, but is not executable." >&2
|
||||
if [ -f "${__cdist_manifest}" ]; then
|
||||
echo "Warning ${__cdist_manifest} exists, but is not executable." >&2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# done with this object
|
||||
touch "$cur_object_dir/$__cdist_name_object_finished"
|
||||
done < "$objectlist"
|
||||
touch "$__cdist_cur_object_dir/$__cdist_name_object_finished"
|
||||
done < "$__cdist_objects_list"
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue