forked from ungleich-public/cdist
		
	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_target_host="$1"; shift
 | 
				
			||||||
__cdist_object_base_dir="$1"; shift
 | 
					__cdist_object_base_dir="$1"; shift
 | 
				
			||||||
 | 
					
 | 
				
			||||||
objectlist="${__cdist_tmp_dir}/objectfile"
 | 
					__cdist_objects_list="${__cdist_tmp_dir}/objects_file"
 | 
				
			||||||
newobjectlist="${__cdist_tmp_dir}/newobjectfile"
 | 
					__cdist_new_objects_list="${__cdist_tmp_dir}/new_objects_file"
 | 
				
			||||||
newobjects="${__cdist_tmp_dir}/newobjects"
 | 
					__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
 | 
					# Loop until we do not create new objects anymore
 | 
				
			||||||
# which is equal to all objects have been run
 | 
					# 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
 | 
					   # 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)
 | 
					   # 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
 | 
					   # Check every object, if we need to run it
 | 
				
			||||||
   while read object; do
 | 
					   while read __cdist_object; do
 | 
				
			||||||
      cur_object_dir="$__cdist_object_base_dir/$object"
 | 
					      __cdist_cur_object_dir="$__cdist_object_base_dir/$__cdist_object"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if [ ! -f "${cur_object_dir}/$__cdist_name_object_finished" ]; then
 | 
					      if [ ! -f "${__cdist_cur_object_dir}/$__cdist_name_object_finished" ]; then
 | 
				
			||||||
         echo "Working on object ${object} ..."
 | 
					         echo "Working on object ${__cdist_object} ..."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         type="${object%%/*}"
 | 
					         __cdist_type="${__cdist_object%%/*}"
 | 
				
			||||||
         manifest="$__cdist_type_dir/${type}/${__cdist_name_manifest}"
 | 
					         __cdist_manifest="$__cdist_type_dir/${__cdist_type}/${__cdist_name_manifest}"
 | 
				
			||||||
         echo $manifest
 | 
					         echo $__cdist_manifest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         if [ -x "${manifest}" ]; then
 | 
					         if [ -x "${__cdist_manifest}" ]; then
 | 
				
			||||||
            echo "Executing manifest ${manifest} ..."
 | 
					            echo "Executing manifest ${__cdist_manifest} ..."
 | 
				
			||||||
            cdist-manifest-run "$__cdist_target_host" "${manifest}" "${newobjects}"
 | 
					            cdist-manifest-run "$__cdist_target_host" "${__cdist_manifest}" "${__cdist_new_objects_dir}"
 | 
				
			||||||
            __cdist_object_list "${newobjects}" > "$newobjectlist"
 | 
					            __cdist_object_list "${__cdist_new_objects_dir}" > "$__cdist_new_objects_list"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # Verify no conflicting objects have been created
 | 
					            # Verify no conflicting objects have been created
 | 
				
			||||||
            while read newobject; do
 | 
					            while read __cdist_new_object; do
 | 
				
			||||||
               grep -q "^$newobject\$" "$objectlist" && \
 | 
					               grep -q "^$__cdist_new_object\$" "$__cdist_objects_list" && \
 | 
				
			||||||
                  __cdist_exit_err "${manifest} tried to recreate ${newobject}"
 | 
					                  __cdist_exit_err "${__cdist_manifest}: Tried to recreate ${__cdist_new_object}"
 | 
				
			||||||
            done < "$newobjectlist"
 | 
					            done < "$__cdist_new_objects_list"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # Safe harbour: We can merge all objects into main tree
 | 
					            # Safe harbour: We can merge all objects into main tree
 | 
				
			||||||
            # Merge = mkdir + mv parameters and source information
 | 
					            # Merge = mkdir + mv parameters and source information
 | 
				
			||||||
            while read newobject; do
 | 
					            while read __cdist_new_object; do
 | 
				
			||||||
                [ "$new_objects_created" = "n" ] && new_objects_created="y"
 | 
					                [ "$__cdist_new_objects_created" = "n" ] && __cdist_new_objects_created="y"
 | 
				
			||||||
               
 | 
					               
 | 
				
			||||||
               set -x
 | 
					               set -x
 | 
				
			||||||
               # where to save the newly created object
 | 
					               # 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
 | 
					               # 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
 | 
					               # Move parameters and source information
 | 
				
			||||||
               mv "${new_object_dir}/"* "$object_dir"
 | 
					               mv "${__cdist_new_object_dir}/"* "$__cdist_object_dir"
 | 
				
			||||||
               mv "${new_object_dir}/${__cdist_name_object_source}" "$object_dir"
 | 
					               mv "${__cdist_new_object_dir}/${__cdist_name_object_source}" "$__cdist_object_dir"
 | 
				
			||||||
               set +x
 | 
					               set +x
 | 
				
			||||||
            done < "$newobjectlist"
 | 
					            done < "$__cdist_new_objects_list"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # Remove listing and rest of newobjects, otherwise the next type will reuse it...
 | 
					            # Remove listing and objects, otherwise the next type will reuse it...
 | 
				
			||||||
            rm -rf "$newobjects" "$newobjectlist"
 | 
					            rm -rf "$__cdist_new_objects_dir" "$__cdist_new_objects_list"
 | 
				
			||||||
         else
 | 
					         else
 | 
				
			||||||
            # Be nice, warn user if manifests exists, but is not executable
 | 
					            # Be nice, warn user if manifests exists, but is not executable
 | 
				
			||||||
            if [ -f "${manifest}" ]; then
 | 
					            if [ -f "${__cdist_manifest}" ]; then
 | 
				
			||||||
               echo "Warning ${manifest} exists, but is not executable." >&2
 | 
					               echo "Warning ${__cdist_manifest} exists, but is not executable." >&2
 | 
				
			||||||
            fi
 | 
					            fi
 | 
				
			||||||
         fi
 | 
					         fi
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      # done with this object
 | 
					      # done with this object
 | 
				
			||||||
      touch "$cur_object_dir/$__cdist_name_object_finished"
 | 
					      touch "$__cdist_cur_object_dir/$__cdist_name_object_finished"
 | 
				
			||||||
   done < "$objectlist"
 | 
					   done < "$__cdist_objects_list"
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue