forked from ungleich-public/cdist
		
	replace some hardcoded values with dynamic generated ones
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								f8a150779e
							
						
					
				
			
			
				commit
				
					
						691766b27e
					
				
			
		
					 2 changed files with 40 additions and 24 deletions
				
			
		| 
						 | 
					@ -28,13 +28,9 @@
 | 
				
			||||||
set -au
 | 
					set -au
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# all types cdist is aware of
 | 
					# all types cdist is aware of
 | 
				
			||||||
export cdist_types="file service user"
 | 
					export __cdist_types="file service user"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# the file that contains mapping from hosts to types
 | 
					cdist_tree_wrapper="cdist_tree_wrapper"
 | 
				
			||||||
# we will execute this later -- call this MANIFEST?
 | 
					 | 
				
			||||||
cdist_config_base="./EXAMPLE_MANIFEST"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cdist_tree_wrapper="./cdist_tree_wrapper"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# used to build the tree and other stuff
 | 
					# used to build the tree and other stuff
 | 
				
			||||||
tmpdir=/tmp/cdist-test-hardcoded
 | 
					tmpdir=/tmp/cdist-test-hardcoded
 | 
				
			||||||
| 
						 | 
					@ -61,7 +57,7 @@ mkdir -p "${cdist_bindir}"
 | 
				
			||||||
(
 | 
					(
 | 
				
			||||||
   set -e
 | 
					   set -e
 | 
				
			||||||
   cd "${cdist_bindir}"
 | 
					   cd "${cdist_bindir}"
 | 
				
			||||||
   for bin in $cdist_types; do
 | 
					   for bin in $__core_types; do
 | 
				
			||||||
      ln -s "${cdist_tree_wrapper_abs}" "${cdist_type_prefix}${bin}"
 | 
					      ln -s "${cdist_tree_wrapper_abs}" "${cdist_type_prefix}${bin}"
 | 
				
			||||||
   done
 | 
					   done
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
| 
						 | 
					@ -77,8 +73,8 @@ PATH="${cdist_bindir}:$PATH"
 | 
				
			||||||
mkdir -p "${cdist_confdir}"
 | 
					mkdir -p "${cdist_confdir}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# force -x, so the user is aware the file is executed
 | 
					# force -x, so the user is aware the file is executed
 | 
				
			||||||
if [ -x "${cdist_config_base}" ]; then
 | 
					if [ -x "${__cdist_manifest_init}" ]; then
 | 
				
			||||||
   "${cdist_config_base}"
 | 
					   "${__cdist_manifest_init}"
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
   echo Throw some error, as you forgot to +x it.
 | 
					   echo Throw some error, as you forgot to +x it.
 | 
				
			||||||
   exit 1
 | 
					   exit 1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,16 +21,22 @@
 | 
				
			||||||
# Print configuration directories - helper for all other scripts
 | 
					# Print configuration directories - helper for all other scripts
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: ${CDIST_CONFIG:=/etc/cdist}
 | 
					: ${__cdist_config:=/etc/cdist}
 | 
				
			||||||
: ${CDIST_COREDIR:=$CDIST_CONFIG/core}
 | 
					: ${__cdist_manifest_dir:=$__cdist_config/manifests}
 | 
				
			||||||
: ${CDIST_LIBDIR:=$CDIST_CONFIG/lib}
 | 
					: ${__cdist_manifest_init:=$__cdist_manifest_dir/init}
 | 
				
			||||||
: ${CDIST_HOSTS:=$CDIST_CONFIG/hosts}
 | 
					: ${__cdist_type_dir:=$__cdist_config/types}
 | 
				
			||||||
: ${CDIST_MODULES:=$CDIST_CONFIG/modules}
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# obsolete?: lib not needed, hosts replaced by manifests, modules by types
 | 
				
			||||||
 | 
					: ${__cdist_hosts:=$__cdist_config/hosts}
 | 
				
			||||||
 | 
					: ${__cdist_modules:=$__cdist_config/modules}
 | 
				
			||||||
 | 
					: ${__cdist_coredir:=$__cdist_config/core}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# create basedir + tempfile for direct usage
 | 
					# create basedir + tempfile for direct usage
 | 
				
			||||||
: ${CDIST_TMPBASEDIR:=/tmp}
 | 
					# FIXME: remove on exit
 | 
				
			||||||
: ${CDIST_TMPDIR:=$(mktemp -d "$CDIST_TMPBASEDIR/cdist.XXXXXXXXXXXX")}
 | 
					: ${__cdist_tmp_dir:=$(mktemp -d "/tmp/cdist.XXXXXXXXXXXX")}
 | 
				
			||||||
: ${CDIST_TMP:=$(mktemp "$CDIST_TMPDIR/cdist.XXXXXXXXXXXX")}
 | 
					: ${__cdist_tmp_file:=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX")}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
################################################################################
 | 
					################################################################################
 | 
				
			||||||
# cconf standard vars prefixed with cdist
 | 
					# cconf standard vars prefixed with cdist
 | 
				
			||||||
| 
						 | 
					@ -41,9 +47,23 @@ __cdist_myname=${0##*/};
 | 
				
			||||||
__cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname"
 | 
					__cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					################################################################################
 | 
				
			||||||
 | 
					# Generate list of types
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# FIXME: ignore error?
 | 
				
			||||||
 | 
					cd "$__cdist_type_dir"
 | 
				
			||||||
 | 
					for __cdist_type in ${__cdist_type_dir}/*; do
 | 
				
			||||||
 | 
					   __cdist_types="$__cdist_types $__cdist_type"
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					cd "$__cdist_abs_mydir"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					################################################################################
 | 
				
			||||||
 | 
					# Function list
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
__cdist_debug_echo()
 | 
					__cdist_debug_echo()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
   if [ "$CDIST_DEBUG" ]; then
 | 
					   if [ "$__cdist_debug" ]; then
 | 
				
			||||||
      echo "Debug: $@"
 | 
					      echo "Debug: $@"
 | 
				
			||||||
   fi
 | 
					   fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -58,20 +78,20 @@ __cdist_usage()
 | 
				
			||||||
#set -e
 | 
					#set -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# load libraries so every program has them available - FIXME
 | 
					# load libraries so every program has them available - FIXME
 | 
				
			||||||
## find "${CDIST_LIBDIR}" -type f > "${CDIST_TMP}"
 | 
					## find "${__cdist_LIBDIR}" -type f > "${__cdist_TMP}"
 | 
				
			||||||
## while read __cdist_lib; do
 | 
					## while read __cdist_lib; do
 | 
				
			||||||
##    __cdist_debug_echo "Loading $__cdist_lib ..."
 | 
					##    __cdist_debug_echo "Loading $__cdist_lib ..."
 | 
				
			||||||
##    . "${__cdist_lib}"
 | 
					##    . "${__cdist_lib}"
 | 
				
			||||||
## done < "${CDIST_TMP}"
 | 
					## done < "${__cdist_TMP}"
 | 
				
			||||||
## 
 | 
					## 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# load modules, all parts => really
 | 
					# load modules, all parts => really
 | 
				
			||||||
#find "${CDIST_MODULES}" -name manifest > "${CDIST_TMP}"
 | 
					#find "${__cdist_MODULES}" -name manifest > "${__cdist_TMP}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#set +e
 | 
					#set +e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#echo $CDIST_CONFIG
 | 
					#echo $__cdist_CONFIG
 | 
				
			||||||
# FIXME: here or somewhere else? other parts may reuse tmp
 | 
					# FIXME: here or somewhere else? other parts may reuse tmp
 | 
				
			||||||
: > "$CDIST_TMP"
 | 
					: > "$__cdist_TMP"
 | 
				
			||||||
#rm -f "$CDIST_TMP"
 | 
					#rm -f "$__cdist_TMP"
 | 
				
			||||||
#__cdist_cur="$(pwd -P)"
 | 
					#__cdist_cur="$(pwd -P)"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue