add python link
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								5429022d61
							
						
					
				
			
			
				commit
				
					
						c5d88435f1
					
				
			
		
					 18 changed files with 1 additions and 874 deletions
				
			
		| 
						 | 
					@ -1,50 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This binary is executed on the remote side to execute code
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 2 ] || __cdist_usage "<object> <type>"
 | 
					 | 
				
			||||||
set -ue
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_object_self="$1"; shift
 | 
					 | 
				
			||||||
__cdist_code_type="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if [ ! -d "$(__cdist_object_dir "$__cdist_object_self")" ]; then
 | 
					 | 
				
			||||||
   __cdist_exit_err "Object undefined"
 | 
					 | 
				
			||||||
fi  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_code="$(__cdist_object_code "$__cdist_object_self" "${__cdist_code_type}")"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_echo info "Checking code-${__cdist_code_type}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if [ -e "$__cdist_code" ]; then
 | 
					 | 
				
			||||||
   if [ -f "$__cdist_code" ]; then
 | 
					 | 
				
			||||||
      if [ -x "$__cdist_code" ]; then
 | 
					 | 
				
			||||||
         __cdist_echo info "Executing code-${__cdist_code_type}"
 | 
					 | 
				
			||||||
         __cdist_exec_fail_on_error "$__cdist_code"
 | 
					 | 
				
			||||||
      else
 | 
					 | 
				
			||||||
         __cdist_exit_err "$__cdist_code exists, but is not executable."
 | 
					 | 
				
			||||||
      fi
 | 
					 | 
				
			||||||
   else
 | 
					 | 
				
			||||||
      __cdist_exit_err "$__cdist_code exists, but is not a file."
 | 
					 | 
				
			||||||
   fi
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,49 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Deploy configuration to a host
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 1 ] || __cdist_usage "<target host>"
 | 
					 | 
				
			||||||
set -eu
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Kill children on interrupt - only in interactive scripts
 | 
					 | 
				
			||||||
trap __cdist_kill_on_interrupt INT TERM
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_target_host="$1"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Make target host available for non-core
 | 
					 | 
				
			||||||
export $__cdist_name_var_target_host="$__cdist_target_host"
 | 
					 | 
				
			||||||
export $__cdist_name_var_target_user="$__cdist_remote_user"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Export variables for core, which others do not reset
 | 
					 | 
				
			||||||
export __cdist_local_base_dir
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_echo info "cdist $__cdist_version: Configuring $__cdist_target_host "
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
################################################################################
 | 
					 | 
				
			||||||
# See cdist-stages(7)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cdist-object-all              "$__cdist_target_host" cdist-object-run
 | 
					 | 
				
			||||||
cdist-cache                   "$__cdist_target_host"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_echo info "cdist $__cdist_version: Successfully finished run"
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,33 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Setup environment for use with cdist - must be standalone!
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export PATH="$(cd "${0%/*}" && pwd -P):$PATH"
 | 
					 | 
				
			||||||
export MANPATH="$(cd "${0%/*}/../doc/man" && pwd -P):$MANPATH"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if [ "$(echo ${SHELL##*/} | grep 'csh$')" ]; then
 | 
					 | 
				
			||||||
   echo setenv PATH $PATH \;
 | 
					 | 
				
			||||||
   echo setenv MANPATH $MANPATH
 | 
					 | 
				
			||||||
else
 | 
					 | 
				
			||||||
   echo export PATH=$PATH
 | 
					 | 
				
			||||||
   echo export MANPATH=$MANPATH
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,43 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Copy & run the global explorers, i.e. not bound to types
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 1 ] || __cdist_usage "<target_host>"
 | 
					 | 
				
			||||||
set -ue
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_target_host="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_echo info "Running global explorers "
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# copy the explorers
 | 
					 | 
				
			||||||
cdist-dir push "$__cdist_target_host" \
 | 
					 | 
				
			||||||
   "${__cdist_explorer_dir}" "${__cdist_remote_explorer_dir}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# run the initial explorers remotely
 | 
					 | 
				
			||||||
cdist-run-remote "${__cdist_target_host}" cdist-remote-explorer-run  \
 | 
					 | 
				
			||||||
   "$__cdist_name_var_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_out_explorer_dir}"
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,56 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2010 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
# Let's build a cconfig tree from a configuration
 | 
					 | 
				
			||||||
# And save it into the cache tree
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 2 ] || __cdist_usage "<target host> <manifest>"
 | 
					 | 
				
			||||||
set -u
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_target_host="$1"; shift
 | 
					 | 
				
			||||||
__cdist_manifest="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
################################################################################
 | 
					 | 
				
			||||||
# Export information for cdist-type-emulator or manifest
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Config dir should not get reset - FIXME: why did I do this?
 | 
					 | 
				
			||||||
export __cdist_conf_dir
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Used to record the source in the object
 | 
					 | 
				
			||||||
export __cdist_manifest
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Export information for manifests - __cdist_out_dir comes from cdist-config
 | 
					 | 
				
			||||||
export __global="$__cdist_out_dir"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
################################################################################
 | 
					 | 
				
			||||||
# The actual run
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Ensure binaries exist and are up-to-date
 | 
					 | 
				
			||||||
cdist-type-build-emulation "${__cdist_out_type_bin_dir}" \
 | 
					 | 
				
			||||||
   || __cdist_exit_err "Failed to build type emulation binaries"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# prepend our path, so all cdist tools come before other tools
 | 
					 | 
				
			||||||
export PATH="${__cdist_out_type_bin_dir}:$PATH"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_exec_fail_on_error "${__cdist_manifest}"
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,34 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
# Let's build a cconfig tree from a configuration
 | 
					 | 
				
			||||||
# And save it into the cache tree
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 1 ] || __cdist_usage "<target host>"
 | 
					 | 
				
			||||||
set -e
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_target_host="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
eval export $__cdist_name_var_manifest=\"\$__cdist_manifest_dir\"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_echo info "Running initial manifest for $__cdist_target_host "
 | 
					 | 
				
			||||||
cdist-manifest-run "$__cdist_target_host" "$__cdist_manifest_init"
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,75 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Deploy configuration to many hosts
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -ge 1 ] || __cdist_usage "[-p] <target host> [target host ]"
 | 
					 | 
				
			||||||
set -u
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Kill children on interrupt - only in interactive scripts
 | 
					 | 
				
			||||||
trap __cdist_kill_on_interrupt INT TERM
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
filter()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   awk -v host=$1 '{ print "[" host "] " $0 }'
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
parallel=""
 | 
					 | 
				
			||||||
if [ "$1" = "-p" ]; then
 | 
					 | 
				
			||||||
   parallel=yes
 | 
					 | 
				
			||||||
   shift
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
i=0
 | 
					 | 
				
			||||||
while [ $# -gt 0 ]; do
 | 
					 | 
				
			||||||
   if [ "$parallel" ]; then
 | 
					 | 
				
			||||||
      cdist-deploy-to "$1" 2>&1 | filter "$1" &
 | 
					 | 
				
			||||||
      # Record pid and host for use later
 | 
					 | 
				
			||||||
      i=$((i+1))
 | 
					 | 
				
			||||||
      eval pid_$i=$!
 | 
					 | 
				
			||||||
      eval host_$i=\$1
 | 
					 | 
				
			||||||
   else
 | 
					 | 
				
			||||||
      cdist-deploy-to "$1" 2>&1 | filter "$1"
 | 
					 | 
				
			||||||
   fi
 | 
					 | 
				
			||||||
   shift
 | 
					 | 
				
			||||||
done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
e=0
 | 
					 | 
				
			||||||
if [ "$parallel" ]; then
 | 
					 | 
				
			||||||
   __cdist_echo info "Waiting for cdist-deploy-to jobs to finish"
 | 
					 | 
				
			||||||
   while [ "$i" -gt 0 ]; do
 | 
					 | 
				
			||||||
      eval pid=\$pid_$i
 | 
					 | 
				
			||||||
      wait "$pid"
 | 
					 | 
				
			||||||
      if [ $? -ne 0 ]; then
 | 
					 | 
				
			||||||
         e=$((e+1))
 | 
					 | 
				
			||||||
         eval e_host_$e=\$host_$i
 | 
					 | 
				
			||||||
      fi
 | 
					 | 
				
			||||||
      i=$((i-1))
 | 
					 | 
				
			||||||
   done
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Display all failed hosts after all runs are done, so the sysadmin gets them
 | 
					 | 
				
			||||||
while [ "$e" -gt 0 ]; do
 | 
					 | 
				
			||||||
   eval host=\$host_$e
 | 
					 | 
				
			||||||
   __cdist_echo error "Configuration of host $host failed."
 | 
					 | 
				
			||||||
   e=$((e-1))
 | 
					 | 
				
			||||||
done
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,56 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
# Run the given command for each created object.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 2 ] || __cdist_usage "<target host> <command>"
 | 
					 | 
				
			||||||
set -eu
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_target_host="$1"; shift
 | 
					 | 
				
			||||||
__cdist_command="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_objects="$__cdist_tmp_dir/objects"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Ensure object dir exists, so marker can be created
 | 
					 | 
				
			||||||
mkdir -p "${__cdist_out_object_dir}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Loop until we do not create new objects anymore
 | 
					 | 
				
			||||||
# which is equal to all objects have been run
 | 
					 | 
				
			||||||
touch "$__cdist_objects_created"
 | 
					 | 
				
			||||||
while [ -f "$__cdist_objects_created" ]; do
 | 
					 | 
				
			||||||
   # Assume we're done after this run
 | 
					 | 
				
			||||||
   rm "$__cdist_objects_created"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   # Get listing of objects
 | 
					 | 
				
			||||||
   __cdist_object_list "$__cdist_out_object_dir" > "$__cdist_objects"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   # NEED TO CREATE ARRAY, SSH DESTROYS WHILE READ LOOP
 | 
					 | 
				
			||||||
   while read __cdist_object; do
 | 
					 | 
				
			||||||
      set -- "$@" "$__cdist_object"
 | 
					 | 
				
			||||||
   done < "$__cdist_objects"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   while [ $# -gt 0 ]; do
 | 
					 | 
				
			||||||
      __cdist_object="$1"; shift
 | 
					 | 
				
			||||||
      $__cdist_command "$__cdist_target_host" "$__cdist_object"
 | 
					 | 
				
			||||||
   done
 | 
					 | 
				
			||||||
done
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,38 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Exec the code for the given object locally and remote
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 2 ] || __cdist_usage "<target host> <object>"
 | 
					 | 
				
			||||||
set -e
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_target_host="$1"; shift
 | 
					 | 
				
			||||||
__cdist_object="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Code local
 | 
					 | 
				
			||||||
export __cdist_out_object_dir="$__cdist_out_object_dir"
 | 
					 | 
				
			||||||
cdist-code-run "$__cdist_object" "${__cdist_name_gencode_local}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Code remote
 | 
					 | 
				
			||||||
cdist-run-remote "$__cdist_target_host" \
 | 
					 | 
				
			||||||
   "cdist-code-run" "$__cdist_object" "${__cdist_name_gencode_remote}"
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,67 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
# Run the explorers for the given object on the target host.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 2 ] || __cdist_usage "<target host> <object>"
 | 
					 | 
				
			||||||
set -eu
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_target_host="$1"; shift
 | 
					 | 
				
			||||||
__cdist_object_self="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_object_id="$(__cdist_object_id_from_object "$__cdist_object_self")"
 | 
					 | 
				
			||||||
__cdist_type="$(__cdist_type_from_object "$__cdist_object_self")"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Check if type of object has >= 1 explorer
 | 
					 | 
				
			||||||
__cdist_has_explorer="$(__cdist_type_has_explorer "$__cdist_type")"
 | 
					 | 
				
			||||||
# Run the type explorers for the current object if any
 | 
					 | 
				
			||||||
if [ "$__cdist_has_explorer" ]; then
 | 
					 | 
				
			||||||
   if ! __cdist_type_explorer_pushed "$__cdist_type"; then
 | 
					 | 
				
			||||||
      src_dir="$(__cdist_type_explorer_dir "$__cdist_type")"
 | 
					 | 
				
			||||||
      dst_dir="$(__cdist_remote_type_explorer_dir "$__cdist_type")"
 | 
					 | 
				
			||||||
      __cdist_echo info "Transfering explorers for $__cdist_type "
 | 
					 | 
				
			||||||
      cdist-dir push "$__cdist_target_host" "$src_dir" "$dst_dir"
 | 
					 | 
				
			||||||
      __cdist_type_explorer_pushed_add "$__cdist_type"
 | 
					 | 
				
			||||||
   fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   __cdist_echo info "Running explorers"
 | 
					 | 
				
			||||||
   # Copy object parameters
 | 
					 | 
				
			||||||
   cdist-dir push "$__cdist_target_host"                          \
 | 
					 | 
				
			||||||
      "$(__cdist_object_parameter_dir "$__cdist_object_self")"         \
 | 
					 | 
				
			||||||
      "$(__cdist_remote_object_parameter_dir "$__cdist_object_self")"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   # Execute explorers
 | 
					 | 
				
			||||||
   cdist-run-remote "$__cdist_target_host"                     \
 | 
					 | 
				
			||||||
      "$__cdist_name_var_object=\"$(__cdist_remote_object_dir "$__cdist_object_self")\"" \
 | 
					 | 
				
			||||||
      "$__cdist_name_var_object_id=\"$__cdist_object_id\""     \
 | 
					 | 
				
			||||||
      "$__cdist_name_var_self=\"$__cdist_object_self\""        \
 | 
					 | 
				
			||||||
      cdist-remote-explorer-run                                \
 | 
					 | 
				
			||||||
      "$__cdist_name_var_type_explorer"                        \
 | 
					 | 
				
			||||||
      "$(__cdist_remote_type_explorer_dir "$__cdist_type")"    \
 | 
					 | 
				
			||||||
      "$(__cdist_remote_object_type_explorer_dir "$__cdist_object_self")"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   # Copy back results
 | 
					 | 
				
			||||||
   cdist-dir pull "$__cdist_target_host"                             \
 | 
					 | 
				
			||||||
      "$(__cdist_remote_object_type_explorer_dir "$__cdist_object_self")" \
 | 
					 | 
				
			||||||
      "$(__cdist_object_type_explorer_dir "$__cdist_object_self")"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,62 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Generate code from one object (object must be relative path!)
 | 
					 | 
				
			||||||
# WARNING: OUTPUT ON STDOUT, ERRORS NEED TO BE ON STDERR!
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 3 ] || __cdist_usage "<target host>" "<object>" "<type>"
 | 
					 | 
				
			||||||
set -eu
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_target_host="$1"; shift
 | 
					 | 
				
			||||||
__cdist_object_self="$1"; shift
 | 
					 | 
				
			||||||
__cdist_gencode_type="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_type="$(__cdist_type_from_object "$__cdist_object_self")"
 | 
					 | 
				
			||||||
__cdist_type_gencode="$(__cdist_type_gencode "$__cdist_type" "$__cdist_gencode_type")"
 | 
					 | 
				
			||||||
__cdist_code_output="$(__cdist_object_code "$__cdist_object_self" "$__cdist_gencode_type")"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# export variables for the gencode script
 | 
					 | 
				
			||||||
export __object_id="$(__cdist_object_id_from_object "$__cdist_object_self")"
 | 
					 | 
				
			||||||
export __object="$(__cdist_object_dir "$__cdist_object_self")"
 | 
					 | 
				
			||||||
export __global="$__cdist_out_dir"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if [ -x "$__cdist_type_gencode" ]; then
 | 
					 | 
				
			||||||
   __cdist_exec_fail_on_error "$__cdist_type_gencode" > "$__cdist_tmp_file"
 | 
					 | 
				
			||||||
else
 | 
					 | 
				
			||||||
   if [ -e "$__cdist_type_gencode" ]; then
 | 
					 | 
				
			||||||
      __cdist_exit_err "$__cdist_type_gencode exists, but is not executable"
 | 
					 | 
				
			||||||
   fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   # Ensure it's empty, if there is no gencode
 | 
					 | 
				
			||||||
   : > "$__cdist_tmp_file"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Only create code, if gencode created output
 | 
					 | 
				
			||||||
if [ "$(wc -l < "$__cdist_tmp_file")" -gt 0 ]; then
 | 
					 | 
				
			||||||
   cat - "$__cdist_tmp_file" << eof > "$__cdist_code_output"
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# The following code was generated by $__cdist_type_gencode
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
eof
 | 
					 | 
				
			||||||
   chmod u+x "${__cdist_code_output}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,38 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2010 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
# For the given object create the code to be executed on the target.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 2 ] || __cdist_usage "<target host> <object>"
 | 
					 | 
				
			||||||
set -eu
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_target_host="$1"; shift
 | 
					 | 
				
			||||||
__cdist_object_self="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_echo info "Generating local code "
 | 
					 | 
				
			||||||
cdist-object-gencode "$__cdist_target_host" "$__cdist_object_self" \
 | 
					 | 
				
			||||||
   "${__cdist_name_gencode_local}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_echo info "Generating remote code "
 | 
					 | 
				
			||||||
cdist-object-gencode "$__cdist_target_host" "$__cdist_object_self" \
 | 
					 | 
				
			||||||
   "${__cdist_name_gencode_remote}"
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,58 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2010 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
# Run the manifest for the given object.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 2 ] || __cdist_usage "<target host> <object>"
 | 
					 | 
				
			||||||
set -eu
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_target_host="$1"; shift
 | 
					 | 
				
			||||||
__cdist_object_self="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# FIXME: rename to __cdist_object_dir (everywhere!)
 | 
					 | 
				
			||||||
__cdist_cur_object_dir="$(__cdist_object_dir "$__cdist_object_self")"
 | 
					 | 
				
			||||||
__cdist_object_id="$(__cdist_object_id_from_object "$__cdist_object_self")"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_echo info "Checking manifest "
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_type="$(__cdist_type_from_object "$__cdist_object_self")"
 | 
					 | 
				
			||||||
__cdist_manifest="$(__cdist_type_manifest "$__cdist_type")"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if [ -f "$__cdist_manifest" ]; then
 | 
					 | 
				
			||||||
   if [ -x "$__cdist_manifest" ]; then
 | 
					 | 
				
			||||||
      # Make __cdist_manifest available for cdist-type-emulator
 | 
					 | 
				
			||||||
      export __cdist_manifest
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      __cdist_echo info "Executing manifest "
 | 
					 | 
				
			||||||
      export $__cdist_name_var_object="$__cdist_cur_object_dir"
 | 
					 | 
				
			||||||
      export $__cdist_name_var_object_id="$__cdist_object_id"
 | 
					 | 
				
			||||||
      export $__cdist_name_var_type="$(__cdist_type_dir "$__cdist_type")"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      cdist-manifest-run "$__cdist_target_host" "$__cdist_manifest"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      # Tell cdist-object-run-all that there may be new objects
 | 
					 | 
				
			||||||
      touch "$__cdist_objects_created"
 | 
					 | 
				
			||||||
   else
 | 
					 | 
				
			||||||
      __cdist_exit_err "${__cdist_manifest} needs to be executable."
 | 
					 | 
				
			||||||
   fi
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,47 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
# For the given object:
 | 
					 | 
				
			||||||
#  - run type explorers
 | 
					 | 
				
			||||||
#  - run type manifest
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 2 ] || __cdist_usage "<target host> <object>"
 | 
					 | 
				
			||||||
set -eu
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_target_host="$1"; shift
 | 
					 | 
				
			||||||
__cdist_object_self="$1"; shift
 | 
					 | 
				
			||||||
__cdist_object_dir="$(__cdist_object_dir "$__cdist_object_self")"
 | 
					 | 
				
			||||||
[ -d "$__cdist_object_dir" ] || __cdist_exit_err "Object undefined"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Export to non-core for use in manifest and gencode scripts
 | 
					 | 
				
			||||||
export $__cdist_name_var_self=$__cdist_object_self
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_object_prepared="$(__cdist_object_prepared "$__cdist_object_self")"
 | 
					 | 
				
			||||||
if [ ! -f "$__cdist_object_prepared" ]; then
 | 
					 | 
				
			||||||
   __cdist_echo info "Preparing object"
 | 
					 | 
				
			||||||
   cdist-object-explorer-run  "$__cdist_target_host" "$__cdist_object_self"
 | 
					 | 
				
			||||||
   cdist-object-manifest-run  "$__cdist_target_host" "$__cdist_object_self"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   # Mark this object as prepared
 | 
					 | 
				
			||||||
   touch "$__cdist_object_prepared"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,35 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2010 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
# Transfer the given object to the target host.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 2 ] || __cdist_usage "<target host> <object>"
 | 
					 | 
				
			||||||
set -eu
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_target_host="$1"; shift
 | 
					 | 
				
			||||||
__cdist_object_self="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_echo info "Transferring object"
 | 
					 | 
				
			||||||
cdist-dir push "$__cdist_target_host" \
 | 
					 | 
				
			||||||
   "$(__cdist_object_dir "$__cdist_object_self")" \
 | 
					 | 
				
			||||||
   "$(__cdist_remote_object_dir "$__cdist_object_self")"
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,65 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
# For the given object:
 | 
					 | 
				
			||||||
#  - run type explorers
 | 
					 | 
				
			||||||
#  - run type manifest
 | 
					 | 
				
			||||||
#  - generate code
 | 
					 | 
				
			||||||
#  - copy object to target
 | 
					 | 
				
			||||||
#  - execute code on target
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 2 ] || __cdist_usage "<target host> <object>"
 | 
					 | 
				
			||||||
set -eu
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_target_host="$1"; shift
 | 
					 | 
				
			||||||
__cdist_object_self="$1"; shift
 | 
					 | 
				
			||||||
__cdist_object_dir="$(__cdist_object_dir "$__cdist_object_self")"
 | 
					 | 
				
			||||||
[ -d "$__cdist_object_dir" ] || __cdist_exit_err "Object undefined"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Export to non-core for use in manifest and gencode scripts
 | 
					 | 
				
			||||||
export $__cdist_name_var_self=$__cdist_object_self
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_object_finished="$(__cdist_object_finished "$__cdist_object_self")"
 | 
					 | 
				
			||||||
if [ ! -f "$__cdist_object_finished" ]; then
 | 
					 | 
				
			||||||
   # Resolve dependencies, if any
 | 
					 | 
				
			||||||
   __cdist_object_require="$(__cdist_object_require "$__cdist_object_self")"
 | 
					 | 
				
			||||||
   if [ -f "$__cdist_object_require" ]; then
 | 
					 | 
				
			||||||
      # NEED TO CREATE ARRAY, SSH DESTROYS WHILE READ LOOP
 | 
					 | 
				
			||||||
      while read __cdist_requirement; do
 | 
					 | 
				
			||||||
         set -- "$@" "$__cdist_requirement"
 | 
					 | 
				
			||||||
      done < "$__cdist_object_require"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      while [ $# -gt 0 ]; do
 | 
					 | 
				
			||||||
         __cdist_requirement="$1"; shift
 | 
					 | 
				
			||||||
         __cdist_echo info "Resolving requirement $__cdist_requirement"
 | 
					 | 
				
			||||||
         cdist-object-run "$__cdist_target_host" "$__cdist_requirement"
 | 
					 | 
				
			||||||
      done
 | 
					 | 
				
			||||||
   fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   cdist-object-gencode-run   "$__cdist_target_host" "$__cdist_object_self"
 | 
					 | 
				
			||||||
   cdist-object-push          "$__cdist_target_host" "$__cdist_object_self"
 | 
					 | 
				
			||||||
   cdist-object-code-run      "$__cdist_target_host" "$__cdist_object_self"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   # Mark this object as done
 | 
					 | 
				
			||||||
   touch "$__cdist_object_finished"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,68 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This file is part of cdist.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
# (at your option) any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# cdist is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This binary is executed on the remote side to execute explorers
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
# It supports different variables names to be used, so __explorers
 | 
					 | 
				
			||||||
# and __type_explorers can be submitted :-)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
. cdist-config
 | 
					 | 
				
			||||||
[ $# -eq 3 ] || __cdist_usage "<variable name> <explorer dir> <out dir>"
 | 
					 | 
				
			||||||
set -ue
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Variable that defines the home of the explorers
 | 
					 | 
				
			||||||
__cdist_variable_name="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Find explorers here
 | 
					 | 
				
			||||||
__cdist_explorer_dir="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Write output here
 | 
					 | 
				
			||||||
__cdist_my_out_dir="$1"; shift
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Setup environment
 | 
					 | 
				
			||||||
export $__cdist_variable_name="$__cdist_explorer_dir"
 | 
					 | 
				
			||||||
export __global="$__cdist_remote_out_dir"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
mkdir -p "$__cdist_my_out_dir"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Ensure there is at least one explorer
 | 
					 | 
				
			||||||
num="$(ls -1 "$__cdist_explorer_dir" | wc -l)"
 | 
					 | 
				
			||||||
if [ "$num" -lt 1 ]; then
 | 
					 | 
				
			||||||
   __cdist_exit_err "${__cdist_explorer_dir}: Contains no explorers"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Execute all explorers
 | 
					 | 
				
			||||||
for explorer in "$__cdist_explorer_dir/"*; do
 | 
					 | 
				
			||||||
   explorer_name="${explorer##*/}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   if [ -f "$explorer" ]; then
 | 
					 | 
				
			||||||
      if [ ! -x "$explorer" ]; then
 | 
					 | 
				
			||||||
         __cdist_exit_err "Explorer \"$explorer\" exists, but is not executable."
 | 
					 | 
				
			||||||
      fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      # Execute explorers and save results in remote destination directory
 | 
					 | 
				
			||||||
      "$explorer" > "${__cdist_my_out_dir}/$explorer_name"
 | 
					 | 
				
			||||||
   else
 | 
					 | 
				
			||||||
      if [ -e "$explorer" ]; then
 | 
					 | 
				
			||||||
         __cdist_exit_err "Explorer \"$explorer\" exists, but is not a file."
 | 
					 | 
				
			||||||
      fi
 | 
					 | 
				
			||||||
   fi
 | 
					 | 
				
			||||||
done
 | 
					 | 
				
			||||||
							
								
								
									
										1
									
								
								bin/cdist.py
									
										
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								bin/cdist.py
									
										
									
									
									
										Symbolic link
									
								
							| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					cdist
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue