a giant commit into the future
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								edc4bf6a47
							
						
					
				
			
			
				commit
				
					
						995bf8d963
					
				
			
		
					 6 changed files with 52 additions and 46 deletions
				
			
		| 
						 | 
				
			
			@ -21,8 +21,9 @@
 | 
			
		|||
# Print configuration directories - helper for all other scripts
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
# Fail if something bogus is going on
 | 
			
		||||
set -u
 | 
			
		||||
# Fail if something bogus is going on and export all variables
 | 
			
		||||
# The export is mainly needed for remote knowledge
 | 
			
		||||
set -au
 | 
			
		||||
 | 
			
		||||
# Values can be overriden from outside, so you can
 | 
			
		||||
# customise paths as you like (for distributors, geeks and hackers)
 | 
			
		||||
| 
						 | 
				
			
			@ -32,6 +33,7 @@ set -u
 | 
			
		|||
: ${__cdist_name_code:=code}
 | 
			
		||||
: ${__cdist_name_explorer:=explorers}
 | 
			
		||||
: ${__cdist_name_gencode:=gencode}
 | 
			
		||||
: ${__cdist_name_helper:=helper}
 | 
			
		||||
: ${__cdist_name_host:=hosts}
 | 
			
		||||
: ${__cdist_name_init:=init}
 | 
			
		||||
: ${__cdist_name_out_dir:=out_dir}
 | 
			
		||||
| 
						 | 
				
			
			@ -61,6 +63,7 @@ set -u
 | 
			
		|||
# Base
 | 
			
		||||
: ${__cdist_config:=/etc/cdist}
 | 
			
		||||
: ${__cdist_explorer_dir:=$__cdist_config/$__cdist_name_explorer}
 | 
			
		||||
: ${__cdist_helper_dir:=$__cdist_config/$__cdist_name_helper}
 | 
			
		||||
: ${__cdist_manifest_dir:=$__cdist_config/$__cdist_name_manifests}
 | 
			
		||||
: ${__cdist_manifest_init:=$__cdist_manifest_dir/$__cdist_name_init}
 | 
			
		||||
: ${__cdist_type_dir:=$__cdist_config/$__cdist_name_type}
 | 
			
		||||
| 
						 | 
				
			
			@ -77,6 +80,7 @@ __cdist_sane_regexp='[A-Za-z0-9]*[-A-Za-z0-9_]*'
 | 
			
		|||
# Remote config
 | 
			
		||||
: ${__cdist_remote_conf_dir:=$__cdist_remote_base_dir/$__cdist_name_conf_dir}
 | 
			
		||||
: ${__cdist_remote_explorer_dir:=$__cdist_remote_conf_dir/$__cdist_name_explorer}
 | 
			
		||||
: ${__cdist_remote_helper_dir:=$__cdist_remote_conf_dir/$__cdist_name_helper}
 | 
			
		||||
 | 
			
		||||
# Remote out
 | 
			
		||||
: ${__cdist_remote_out_dir:=$__cdist_remote_base_dir/$__cdist_name_out_dir}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,10 +27,20 @@ set -eu
 | 
			
		|||
 | 
			
		||||
__cdist_target_host="$1"
 | 
			
		||||
 | 
			
		||||
################################################################################
 | 
			
		||||
# See cdist-stages(7)
 | 
			
		||||
cdist-explorer-run-init       "$__cdist_target_host" "$__cdist_out_explorer_dir"
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
# Transfer core helpers plus cdist-config
 | 
			
		||||
cdist-dir push "$__cdist_target_host" "${__cdist_helper_dir}" "${__cdist_remote_helper_dir}"
 | 
			
		||||
scp "$(which cdist-config)" \
 | 
			
		||||
   "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_remote_helper_dir}"
 | 
			
		||||
 | 
			
		||||
exit 2
 | 
			
		||||
 | 
			
		||||
# Execute explorer
 | 
			
		||||
cdist-explorer-run-init       "$__cdist_target_host" "$__cdist_out_explorer_dir"
 | 
			
		||||
 | 
			
		||||
cdist-manifest-init           "$__cdist_target_host" "$__cdist_out_object_dir"
 | 
			
		||||
cdist-manifest-run-all        "$__cdist_target_host" "$__cdist_out_object_dir"
 | 
			
		||||
cdist-object-explorer-all     "$__cdist_target_host" "$__cdist_out_object_dir"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,25 +24,18 @@
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
. cdist-config
 | 
			
		||||
if [ $# -lt 5 ]; then
 | 
			
		||||
   __cdist_usage "<target host> <local srcdir> <local dstdir> <remote srcdir> <remote dstdir> [explorer args]"
 | 
			
		||||
if [ $# -lt 3 ]; then
 | 
			
		||||
   __cdist_usage "<target host> <remote srcdir> <remote dstdir> [explorer args]"
 | 
			
		||||
fi
 | 
			
		||||
set -ue
 | 
			
		||||
 | 
			
		||||
__cdist_target_host="$1"; shift
 | 
			
		||||
 | 
			
		||||
__cdist_local_src_dir="$1"; shift
 | 
			
		||||
__cdist_local_dst_dir="$1"; shift
 | 
			
		||||
__cdist_remote_src_dir="$1"; shift
 | 
			
		||||
__cdist_remote_dst_dir="$1"; shift
 | 
			
		||||
 | 
			
		||||
# Create remote source and destination directory
 | 
			
		||||
# Create remote destination directory
 | 
			
		||||
ssh "${__cdist_remote_user}@${__cdist_target_host}"   \
 | 
			
		||||
      "mkdir -p   \"${__cdist_remote_src_dir}\"       \
 | 
			
		||||
                  \"${__cdist_remote_dst_dir}\""
 | 
			
		||||
 | 
			
		||||
# Ensure local destination directory exists
 | 
			
		||||
mkdir -p "$__cdist_local_dst_dir"
 | 
			
		||||
      "mkdir -p \"${__cdist_remote_dst_dir}\""
 | 
			
		||||
 | 
			
		||||
# FIXME: enable -q as soon as the code is cleaned up
 | 
			
		||||
cd "${__cdist_local_src_dir}"
 | 
			
		||||
| 
						 | 
				
			
			@ -53,9 +46,6 @@ if [ "$num" -lt 1 ]; then
 | 
			
		|||
   __cdist_exit_err "${__cdist_local_src_dir}: Contains no explorers"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Copy all explorers to remote source directory
 | 
			
		||||
scp * "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_remote_src_dir}"
 | 
			
		||||
 | 
			
		||||
# Execute all explorers
 | 
			
		||||
for explorer in *; do
 | 
			
		||||
   if [ -f "$explorer" ]; then
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,16 +18,24 @@
 | 
			
		|||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
# Run the global explorers, i.e. not bound to types
 | 
			
		||||
# Copy & run the general explorers, i.e. not bound to types
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
. cdist-config
 | 
			
		||||
[ $# -eq 2 ] || __cdist_usage "<target host> <outdir>"
 | 
			
		||||
[ $# -eq 2 ] || __cdist_usage "<target_host> <out_dir>"
 | 
			
		||||
set -ue
 | 
			
		||||
 | 
			
		||||
__cdist_target_host="$1"; shift
 | 
			
		||||
__cdist_output_dir="$1"; shift
 | 
			
		||||
__cdist_my_out_dir="$1"; shift
 | 
			
		||||
 | 
			
		||||
# copy the explorers
 | 
			
		||||
cdist-dir push "$__cdist_target_host" \
 | 
			
		||||
   "${__cdist_explorer_dir}" "${__cdist_remote_explorer_dir}"
 | 
			
		||||
 | 
			
		||||
# run the explorers remotely
 | 
			
		||||
cdist-explorer-run "$__cdist_target_host"          \
 | 
			
		||||
   "$__cdist_explorer_dir" "$__cdist_output_dir"   \
 | 
			
		||||
   "$__cdist_remote_explorer_dir" "$__cdist_remote_cache_explorer"
 | 
			
		||||
   "$__cdist_remote_explorer_dir" "$__cdist_remote_out_explorer_dir"
 | 
			
		||||
 | 
			
		||||
# retrieve the results
 | 
			
		||||
cdist-dir pull "$__cdist_target_host" \
 | 
			
		||||
   "${__cdist_remote_out_explorer_dir}" "${__cdist_my_out_dir}"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,6 +59,10 @@ while [ $# -gt 0 ]; do
 | 
			
		|||
   # Copy directory, needs to be one level above, otherwise subdir is created
 | 
			
		||||
   # FIXME: add -q later
 | 
			
		||||
   ssh "${__cdist_remote_user}@${__cdist_target_host}" "mkdir -p \"$remote_object_dir\""
 | 
			
		||||
 | 
			
		||||
   # 
 | 
			
		||||
   ssh "${__cdist_remote_user}@${__cdist_target_host}" "mkdir -p \"$remote_object_dir\""
 | 
			
		||||
 | 
			
		||||
   scp -r "$local_params_dir" "${__cdist_remote_user}@${__cdist_target_host}:$remote_object_dir"
 | 
			
		||||
 | 
			
		||||
   if [ -d "$local_src_dir" ]; then
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
#!/bin/sh
 | 
			
		||||
#
 | 
			
		||||
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
			
		||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
			
		||||
#
 | 
			
		||||
# This file is part of cdist.
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -18,36 +18,32 @@
 | 
			
		|||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
# FIXME: Replace * references: * breaks if there is no explorer
 | 
			
		||||
# or FIXME: check that there is at least one explorer?
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
. cdist-config
 | 
			
		||||
if [ $# -lt 3 ]; then
 | 
			
		||||
   __cdist_usage "<target host> <remote srcdir> <remote dstdir> [explorer args]"
 | 
			
		||||
   __cdist_usage "<work dir> <explorer dir> <out dir> [explorer args]"
 | 
			
		||||
fi
 | 
			
		||||
set -ue
 | 
			
		||||
 | 
			
		||||
__cdist_target_host="$1"; shift
 | 
			
		||||
__cdist_remote_src_dir="$1"; shift
 | 
			
		||||
__cdist_remote_dst_dir="$1"; shift
 | 
			
		||||
# cd to this dir
 | 
			
		||||
__cdist_work_dir="$1"; shift
 | 
			
		||||
 | 
			
		||||
# Create remote destination directory
 | 
			
		||||
ssh "${__cdist_remote_user}@${__cdist_target_host}"   \
 | 
			
		||||
      "mkdir -p \"${__cdist_remote_dst_dir}\""
 | 
			
		||||
# find explorers here
 | 
			
		||||
__cdist_explorer_dir="$1"; shift
 | 
			
		||||
 | 
			
		||||
# FIXME: enable -q as soon as the code is cleaned up
 | 
			
		||||
cd "${__cdist_local_src_dir}"
 | 
			
		||||
# write output here
 | 
			
		||||
__cdist_my_out_dir="$1"; shift
 | 
			
		||||
 | 
			
		||||
cd "${__cdist_work_dir}"
 | 
			
		||||
 | 
			
		||||
# Ensure there is at least one explorer
 | 
			
		||||
num="$(ls -1 | wc -l)"
 | 
			
		||||
num="$(ls -1 "$__cdist_explorer_dir" | wc -l)"
 | 
			
		||||
if [ "$num" -lt 1 ]; then
 | 
			
		||||
   __cdist_exit_err "${__cdist_local_src_dir}: Contains no explorers"
 | 
			
		||||
   __cdist_exit_err "${__cdist_explorer_dir}: Contains no explorers"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Execute all explorers
 | 
			
		||||
for explorer in *; do
 | 
			
		||||
for explorer in "$__cdist_explorer_dir/"*; do
 | 
			
		||||
   if [ -f "$explorer" ]; then
 | 
			
		||||
      if [ ! -x "$explorer" ]; then
 | 
			
		||||
         echo "Explorer \"$explorer\" exists, but is not executable."
 | 
			
		||||
| 
						 | 
				
			
			@ -55,9 +51,7 @@ for explorer in *; do
 | 
			
		|||
      fi
 | 
			
		||||
 | 
			
		||||
      # Execute explorers and save results in remote destination directory
 | 
			
		||||
      ssh "${__cdist_remote_user}@${__cdist_target_host}" \
 | 
			
		||||
          "cd \"${__cdist_remote_src_dir}\" && \"./$explorer\" > \
 | 
			
		||||
          \"${__cdist_remote_dst_dir}/${explorer}\"" "$@"
 | 
			
		||||
      "$explorer" "$@" > "${__cdist_my_out_dir}"
 | 
			
		||||
   else
 | 
			
		||||
      if [ -e "$explorer" ]; then
 | 
			
		||||
         echo "Explorer \"$explorer\" exists, but is not a file."
 | 
			
		||||
| 
						 | 
				
			
			@ -65,7 +59,3 @@ for explorer in *; do
 | 
			
		|||
      fi
 | 
			
		||||
   fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
# Copy results back to us
 | 
			
		||||
scp "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_remote_dst_dir}/*" \
 | 
			
		||||
    "$__cdist_local_dst_dir"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue