From c5d88435f13e46a0b8066ce9cf904fafa7696050 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 11 Sep 2011 21:24:23 +0200 Subject: [PATCH] add python link Signed-off-by: Nico Schottelius --- bin/cdist-code-run | 50 ----------------------- bin/cdist-deploy-to | 49 ----------------------- bin/cdist-env | 33 --------------- bin/cdist-explorer-run-global | 43 -------------------- bin/cdist-manifest-run | 56 -------------------------- bin/cdist-manifest-run-init | 34 ---------------- bin/cdist-mass-deploy | 75 ----------------------------------- bin/cdist-object-all | 56 -------------------------- bin/cdist-object-code-run | 38 ------------------ bin/cdist-object-explorer-run | 67 ------------------------------- bin/cdist-object-gencode | 62 ----------------------------- bin/cdist-object-gencode-run | 38 ------------------ bin/cdist-object-manifest-run | 58 --------------------------- bin/cdist-object-prepare | 47 ---------------------- bin/cdist-object-push | 35 ---------------- bin/cdist-object-run | 65 ------------------------------ bin/cdist-remote-explorer-run | 68 ------------------------------- bin/cdist.py | 1 + 18 files changed, 1 insertion(+), 874 deletions(-) delete mode 100755 bin/cdist-code-run delete mode 100755 bin/cdist-deploy-to delete mode 100755 bin/cdist-env delete mode 100755 bin/cdist-explorer-run-global delete mode 100755 bin/cdist-manifest-run delete mode 100755 bin/cdist-manifest-run-init delete mode 100755 bin/cdist-mass-deploy delete mode 100755 bin/cdist-object-all delete mode 100755 bin/cdist-object-code-run delete mode 100755 bin/cdist-object-explorer-run delete mode 100755 bin/cdist-object-gencode delete mode 100755 bin/cdist-object-gencode-run delete mode 100755 bin/cdist-object-manifest-run delete mode 100755 bin/cdist-object-prepare delete mode 100755 bin/cdist-object-push delete mode 100755 bin/cdist-object-run delete mode 100755 bin/cdist-remote-explorer-run create mode 120000 bin/cdist.py diff --git a/bin/cdist-code-run b/bin/cdist-code-run deleted file mode 100755 index 3d7499bf..00000000 --- a/bin/cdist-code-run +++ /dev/null @@ -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 . -# -# -# This binary is executed on the remote side to execute code -# - -. cdist-config -[ $# -eq 2 ] || __cdist_usage " " -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 diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to deleted file mode 100755 index 86e15800..00000000 --- a/bin/cdist-deploy-to +++ /dev/null @@ -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 . -# -# -# Deploy configuration to a host -# - -. cdist-config -[ $# -eq 1 ] || __cdist_usage "" -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" diff --git a/bin/cdist-env b/bin/cdist-env deleted file mode 100755 index 2aac5e6b..00000000 --- a/bin/cdist-env +++ /dev/null @@ -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 . -# -# -# 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 diff --git a/bin/cdist-explorer-run-global b/bin/cdist-explorer-run-global deleted file mode 100755 index b0c024f2..00000000 --- a/bin/cdist-explorer-run-global +++ /dev/null @@ -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 . -# -# -# Copy & run the global explorers, i.e. not bound to types -# - -. cdist-config -[ $# -eq 1 ] || __cdist_usage "" -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}" diff --git a/bin/cdist-manifest-run b/bin/cdist-manifest-run deleted file mode 100755 index d4ea18bb..00000000 --- a/bin/cdist-manifest-run +++ /dev/null @@ -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 . -# -# -# Let's build a cconfig tree from a configuration -# And save it into the cache tree -# - -. cdist-config -[ $# -eq 2 ] || __cdist_usage " " -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}" diff --git a/bin/cdist-manifest-run-init b/bin/cdist-manifest-run-init deleted file mode 100755 index 28acc623..00000000 --- a/bin/cdist-manifest-run-init +++ /dev/null @@ -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 . -# -# -# Let's build a cconfig tree from a configuration -# And save it into the cache tree -# - -. cdist-config -[ $# -eq 1 ] || __cdist_usage "" -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" diff --git a/bin/cdist-mass-deploy b/bin/cdist-mass-deploy deleted file mode 100755 index c2b6d6a5..00000000 --- a/bin/cdist-mass-deploy +++ /dev/null @@ -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 . -# -# -# Deploy configuration to many hosts -# - -. cdist-config -[ $# -ge 1 ] || __cdist_usage "[-p] [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 diff --git a/bin/cdist-object-all b/bin/cdist-object-all deleted file mode 100755 index 391c9cc7..00000000 --- a/bin/cdist-object-all +++ /dev/null @@ -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 . -# -# -# Run the given command for each created object. -# - -. cdist-config -[ $# -eq 2 ] || __cdist_usage " " -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 diff --git a/bin/cdist-object-code-run b/bin/cdist-object-code-run deleted file mode 100755 index fa63aaba..00000000 --- a/bin/cdist-object-code-run +++ /dev/null @@ -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 . -# -# -# Exec the code for the given object locally and remote -# - -. cdist-config -[ $# -eq 2 ] || __cdist_usage " " -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}" diff --git a/bin/cdist-object-explorer-run b/bin/cdist-object-explorer-run deleted file mode 100755 index b65c5cc1..00000000 --- a/bin/cdist-object-explorer-run +++ /dev/null @@ -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 . -# -# -# Run the explorers for the given object on the target host. -# - -. cdist-config -[ $# -eq 2 ] || __cdist_usage " " -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 diff --git a/bin/cdist-object-gencode b/bin/cdist-object-gencode deleted file mode 100755 index e21568a3..00000000 --- a/bin/cdist-object-gencode +++ /dev/null @@ -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 . -# -# -# 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 "" "" "" -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 diff --git a/bin/cdist-object-gencode-run b/bin/cdist-object-gencode-run deleted file mode 100755 index 254ac1e4..00000000 --- a/bin/cdist-object-gencode-run +++ /dev/null @@ -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 . -# -# -# For the given object create the code to be executed on the target. -# - -. cdist-config -[ $# -eq 2 ] || __cdist_usage " " -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}" diff --git a/bin/cdist-object-manifest-run b/bin/cdist-object-manifest-run deleted file mode 100755 index 34d4f867..00000000 --- a/bin/cdist-object-manifest-run +++ /dev/null @@ -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 . -# -# -# Run the manifest for the given object. -# - -. cdist-config -[ $# -eq 2 ] || __cdist_usage " " -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 diff --git a/bin/cdist-object-prepare b/bin/cdist-object-prepare deleted file mode 100755 index d21d8a63..00000000 --- a/bin/cdist-object-prepare +++ /dev/null @@ -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 . -# -# -# For the given object: -# - run type explorers -# - run type manifest -# - -. cdist-config -[ $# -eq 2 ] || __cdist_usage " " -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 diff --git a/bin/cdist-object-push b/bin/cdist-object-push deleted file mode 100755 index 62b00cb2..00000000 --- a/bin/cdist-object-push +++ /dev/null @@ -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 . -# -# -# Transfer the given object to the target host. -# - -. cdist-config -[ $# -eq 2 ] || __cdist_usage " " -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")" diff --git a/bin/cdist-object-run b/bin/cdist-object-run deleted file mode 100755 index 4f40e7c1..00000000 --- a/bin/cdist-object-run +++ /dev/null @@ -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 . -# -# -# 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 " " -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 diff --git a/bin/cdist-remote-explorer-run b/bin/cdist-remote-explorer-run deleted file mode 100755 index d95913ba..00000000 --- a/bin/cdist-remote-explorer-run +++ /dev/null @@ -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 . -# -# -# 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 " " -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 diff --git a/bin/cdist.py b/bin/cdist.py new file mode 120000 index 00000000..9a039b33 --- /dev/null +++ b/bin/cdist.py @@ -0,0 +1 @@ +cdist \ No newline at end of file