2010-09-19 12:13:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2011-02-17 16:46:18 +00:00
|
|
|
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
|
2010-09-19 12:13:13 +00:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2011-06-17 08:34:52 +00:00
|
|
|
__cdist_version="1.8.0"
|
2011-03-11 18:25:55 +00:00
|
|
|
|
2011-03-11 18:09:36 +00:00
|
|
|
# Fail if something bogus is going on
|
2011-02-24 13:28:29 +00:00
|
|
|
set -u
|
2011-02-05 18:32:29 +00:00
|
|
|
|
2011-06-14 09:14:24 +00:00
|
|
|
# Fail if exited non-zero as well
|
|
|
|
set -e
|
|
|
|
|
2011-03-03 13:49:48 +00:00
|
|
|
################################################################################
|
|
|
|
# cconf standard vars prefixed with cdist
|
2011-03-04 01:08:05 +00:00
|
|
|
|
2011-03-03 13:49:48 +00:00
|
|
|
__cdist_pwd="$(pwd -P)"
|
|
|
|
__cdist_mydir="${0%/*}";
|
|
|
|
__cdist_abs_mydir="$(cd "$__cdist_mydir" && pwd -P)"
|
|
|
|
__cdist_myname=${0##*/};
|
|
|
|
__cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname"
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Names / Constants
|
|
|
|
#
|
2011-02-25 00:48:18 +00:00
|
|
|
# Most values can be overriden from outside, so you can
|
2011-02-02 20:49:01 +00:00
|
|
|
# customise paths as you like (for distributors, geeks and hackers)
|
2011-03-03 13:49:48 +00:00
|
|
|
#
|
2011-02-02 13:23:54 +00:00
|
|
|
|
2011-02-05 18:41:47 +00:00
|
|
|
: ${__cdist_name_bin:=bin}
|
2011-03-25 22:35:11 +00:00
|
|
|
: ${__cdist_name_cache:=cache}
|
2011-02-07 23:26:26 +00:00
|
|
|
: ${__cdist_name_code:=code}
|
2011-02-24 23:14:26 +00:00
|
|
|
: ${__cdist_name_conf_dir:=conf}
|
2011-06-13 22:28:08 +00:00
|
|
|
: ${__cdist_name_core_dir:=core}
|
2011-03-21 15:18:04 +00:00
|
|
|
: ${__cdist_name_dot_cdist:=.cdist}
|
2011-02-24 20:32:01 +00:00
|
|
|
: ${__cdist_name_explorer:=explorer}
|
2011-02-14 10:28:14 +00:00
|
|
|
: ${__cdist_name_gencode:=gencode}
|
2011-03-19 21:19:44 +00:00
|
|
|
: ${__cdist_name_gencode_local:=local}
|
|
|
|
: ${__cdist_name_gencode_remote:=remote}
|
2011-03-03 09:37:11 +00:00
|
|
|
: ${__cdist_name_global:=global}
|
2011-02-24 20:32:01 +00:00
|
|
|
: ${__cdist_name_host:=host}
|
2011-02-05 18:41:47 +00:00
|
|
|
: ${__cdist_name_init:=init}
|
2011-02-24 13:47:52 +00:00
|
|
|
: ${__cdist_name_manifest:=manifest}
|
2011-02-24 14:34:17 +00:00
|
|
|
: ${__cdist_name_object:=object}
|
2011-03-23 10:45:50 +00:00
|
|
|
: ${__cdist_name_object_finished:=done}
|
2011-04-05 20:55:46 +00:00
|
|
|
: ${__cdist_name_object_prepared:=prepared}
|
2011-02-24 14:34:17 +00:00
|
|
|
: ${__cdist_name_object_id:=object_id}
|
2011-03-23 10:45:50 +00:00
|
|
|
: ${__cdist_name_object_source:=source}
|
2011-03-29 12:36:35 +00:00
|
|
|
: ${__cdist_name_objects_created:=.objects_created}
|
2011-02-24 23:14:26 +00:00
|
|
|
: ${__cdist_name_out_dir:=out}
|
2011-02-24 20:32:01 +00:00
|
|
|
: ${__cdist_name_parameter:=parameter}
|
|
|
|
: ${__cdist_name_parameter_required:=required}
|
|
|
|
: ${__cdist_name_parameter_optional:=optional}
|
2011-03-16 14:49:28 +00:00
|
|
|
: ${__cdist_name_require:=require}
|
2011-03-29 13:27:17 +00:00
|
|
|
: ${__cdist_name_self:=self}
|
2011-03-09 21:09:44 +00:00
|
|
|
: ${__cdist_name_singleton:=singleton}
|
2011-02-24 14:05:31 +00:00
|
|
|
: ${__cdist_name_target_host:=target_host}
|
2011-03-20 01:44:31 +00:00
|
|
|
: ${__cdist_name_target_user:=target_user}
|
2011-02-24 20:32:01 +00:00
|
|
|
: ${__cdist_name_type:=type}
|
2011-02-23 17:40:58 +00:00
|
|
|
: ${__cdist_name_type_bin:=type_bin}
|
2011-02-24 20:32:01 +00:00
|
|
|
: ${__cdist_name_type_explorer:=type_explorer}
|
2011-03-29 12:36:35 +00:00
|
|
|
: ${__cdist_name_type_explorer_pushed:=.explorer_pushed}
|
2011-02-24 20:32:01 +00:00
|
|
|
|
2011-03-10 16:19:25 +00:00
|
|
|
# Used for IDs: Allow everything not starting with - and .
|
2011-03-10 16:25:24 +00:00
|
|
|
: ${__cdist_sane_regexp:=[^-\.].*}
|
2011-02-17 08:17:13 +00:00
|
|
|
|
2011-03-03 13:49:48 +00:00
|
|
|
# Default remote user
|
|
|
|
: ${__cdist_remote_user:=root}
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
2011-06-13 22:41:52 +00:00
|
|
|
# Exported variable names (usable for non core)
|
2011-03-03 13:49:48 +00:00
|
|
|
#
|
2011-02-24 13:24:47 +00:00
|
|
|
: ${__cdist_name_var_explorer:=__$__cdist_name_explorer}
|
2011-02-24 20:32:01 +00:00
|
|
|
: ${__cdist_name_var_type_explorer:=__$__cdist_name_type_explorer}
|
2011-03-03 09:37:11 +00:00
|
|
|
: ${__cdist_name_var_global:=__$__cdist_name_global}
|
2011-02-24 20:32:01 +00:00
|
|
|
: ${__cdist_name_var_manifest:=__$__cdist_name_manifest}
|
2011-02-24 14:05:31 +00:00
|
|
|
: ${__cdist_name_var_target_host:=__$__cdist_name_target_host}
|
2011-03-20 01:44:31 +00:00
|
|
|
: ${__cdist_name_var_target_user:=__$__cdist_name_target_user}
|
2011-02-24 14:34:17 +00:00
|
|
|
: ${__cdist_name_var_object:=__$__cdist_name_object}
|
|
|
|
: ${__cdist_name_var_object_id:=__$__cdist_name_object_id}
|
2011-03-29 13:27:17 +00:00
|
|
|
: ${__cdist_name_var_self:=__$__cdist_name_self}
|
2011-02-25 17:42:38 +00:00
|
|
|
: ${__cdist_name_var_type:=__$__cdist_name_type}
|
2011-02-17 08:17:13 +00:00
|
|
|
|
2011-02-16 19:12:29 +00:00
|
|
|
|
2011-03-03 14:27:51 +00:00
|
|
|
################################################################################
|
|
|
|
# Tempfiles
|
|
|
|
#
|
2011-04-08 08:51:27 +00:00
|
|
|
: ${__cdist_tmp_base_dir=/tmp}
|
|
|
|
__cdist_tmp_dir=$(mktemp -d "$__cdist_tmp_base_dir/cdist.XXXXXXXXXXXX")
|
2011-03-03 14:27:51 +00:00
|
|
|
__cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX")
|
|
|
|
|
2011-03-03 13:49:48 +00:00
|
|
|
################################################################################
|
2011-03-03 09:37:11 +00:00
|
|
|
# Local Base
|
2011-03-03 13:49:48 +00:00
|
|
|
#
|
2011-03-03 14:27:51 +00:00
|
|
|
: ${__cdist_local_base_dir:=$__cdist_tmp_dir}
|
2011-03-31 13:40:08 +00:00
|
|
|
|
|
|
|
# Cache may *NOT* be below __cdist_local_base_dir!
|
2011-03-25 22:35:11 +00:00
|
|
|
: ${__cdist_local_base_cache_dir:=$__cdist_abs_mydir/../$__cdist_name_cache}
|
2011-03-03 14:27:51 +00:00
|
|
|
|
|
|
|
: ${__cdist_conf_dir:="$(cd "$__cdist_abs_mydir/../conf" && pwd -P)"}
|
2011-06-13 22:28:08 +00:00
|
|
|
: ${__cdist_core_dir:="$(cd "$__cdist_abs_mydir/../$__cdist_name_core_dir" && pwd -P)"}
|
2011-03-03 14:27:51 +00:00
|
|
|
|
2011-02-23 18:01:29 +00:00
|
|
|
: ${__cdist_explorer_dir:=$__cdist_conf_dir/$__cdist_name_explorer}
|
2011-02-24 20:32:01 +00:00
|
|
|
: ${__cdist_manifest_dir:=$__cdist_conf_dir/$__cdist_name_manifest}
|
2011-02-05 18:41:47 +00:00
|
|
|
: ${__cdist_manifest_init:=$__cdist_manifest_dir/$__cdist_name_init}
|
2011-02-23 18:01:29 +00:00
|
|
|
: ${__cdist_type_dir:=$__cdist_conf_dir/$__cdist_name_type}
|
2011-02-02 13:01:21 +00:00
|
|
|
|
2011-03-03 13:49:48 +00:00
|
|
|
################################################################################
|
|
|
|
# Local output
|
|
|
|
#
|
2011-03-03 09:37:11 +00:00
|
|
|
: ${__cdist_out_dir:=$__cdist_local_base_dir/$__cdist_name_out_dir}
|
|
|
|
: ${__cdist_out_explorer_dir:=$__cdist_out_dir/$__cdist_name_explorer}
|
|
|
|
: ${__cdist_out_object_dir:=$__cdist_out_dir/$__cdist_name_object}
|
2011-03-29 12:36:35 +00:00
|
|
|
: ${__cdist_out_type_dir:=$__cdist_out_dir/$__cdist_name_type}
|
2011-03-03 09:37:11 +00:00
|
|
|
: ${__cdist_out_type_bin_dir:=$__cdist_out_dir/$__cdist_name_type_bin}
|
2011-02-22 19:40:54 +00:00
|
|
|
|
2011-03-29 14:27:57 +00:00
|
|
|
: ${__cdist_objects_created:=$__cdist_out_object_dir/$__cdist_name_objects_created}
|
|
|
|
|
2011-03-03 13:49:48 +00:00
|
|
|
################################################################################
|
2011-02-23 15:19:41 +00:00
|
|
|
# Remote base
|
2011-03-03 13:49:48 +00:00
|
|
|
#
|
2011-02-04 13:38:17 +00:00
|
|
|
: ${__cdist_remote_base_dir:=/var/lib/cdist}
|
2011-03-03 14:27:51 +00:00
|
|
|
: ${__cdist_remote_bin_dir:=$__cdist_remote_base_dir/$__cdist_name_bin}
|
2011-02-23 15:19:41 +00:00
|
|
|
: ${__cdist_remote_conf_dir:=$__cdist_remote_base_dir/$__cdist_name_conf_dir}
|
2011-06-13 22:28:08 +00:00
|
|
|
: ${__cdist_remote_core_dir:=$__cdist_remote_base_dir/$__cdist_name_core_dir}
|
2011-03-03 14:27:51 +00:00
|
|
|
|
2011-02-23 15:19:41 +00:00
|
|
|
: ${__cdist_remote_explorer_dir:=$__cdist_remote_conf_dir/$__cdist_name_explorer}
|
2011-02-24 15:33:08 +00:00
|
|
|
: ${__cdist_remote_type_dir:=$__cdist_remote_conf_dir/$__cdist_name_type}
|
2011-02-23 15:19:41 +00:00
|
|
|
|
2011-03-03 13:49:48 +00:00
|
|
|
################################################################################
|
|
|
|
# Remote output
|
|
|
|
#
|
2011-02-23 15:19:41 +00:00
|
|
|
: ${__cdist_remote_out_dir:=$__cdist_remote_base_dir/$__cdist_name_out_dir}
|
|
|
|
: ${__cdist_remote_out_explorer_dir:=$__cdist_remote_out_dir/$__cdist_name_explorer}
|
2011-03-26 00:43:55 +00:00
|
|
|
: ${__cdist_remote_out_object_dir:=$__cdist_remote_out_dir/$__cdist_name_object}
|
2011-02-04 13:38:17 +00:00
|
|
|
|
2011-03-29 12:36:35 +00:00
|
|
|
|
2011-02-02 13:01:21 +00:00
|
|
|
################################################################################
|
2011-03-23 10:12:39 +00:00
|
|
|
# Internal functions
|
2011-02-02 13:01:21 +00:00
|
|
|
#
|
2011-06-13 22:17:31 +00:00
|
|
|
|
|
|
|
# *NEW* Load functions from library
|
|
|
|
for __cdist_lib in $__cdist_core_dir/*; do
|
2011-06-13 22:48:07 +00:00
|
|
|
# echo Loading $__cdist_lib ...
|
2011-06-13 22:17:31 +00:00
|
|
|
. "$__cdist_lib"
|
|
|
|
done
|
|
|
|
|
2010-09-19 12:30:36 +00:00
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
__cdist_exec_fail_on_error()
|
|
|
|
{
|
2011-04-06 18:18:31 +00:00
|
|
|
set +e
|
2011-03-23 10:12:39 +00:00
|
|
|
sh -e "$@"
|
2011-04-06 18:00:36 +00:00
|
|
|
if [ "$?" -ne 0 ]; then
|
2011-04-06 18:55:53 +00:00
|
|
|
__cdist_echo error "$1 exited non-zero"
|
2011-04-06 19:18:15 +00:00
|
|
|
__cdist_echo warn "Faulty code:"
|
2011-04-06 18:05:58 +00:00
|
|
|
cat "$1"
|
|
|
|
__cdist_exit_err "Aborting due to non-zero exit code."
|
2011-04-06 18:00:36 +00:00
|
|
|
fi
|
2011-03-23 10:12:39 +00:00
|
|
|
}
|
|
|
|
|
2011-02-02 13:55:28 +00:00
|
|
|
__cdist_exit_err()
|
2010-09-29 16:55:18 +00:00
|
|
|
{
|
2011-04-06 18:00:36 +00:00
|
|
|
__cdist_echo error "$@"
|
2010-09-29 16:55:18 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2011-02-02 13:55:28 +00:00
|
|
|
__cdist_usage()
|
|
|
|
{
|
|
|
|
__cdist_exit_err "$__cdist_myname: $@"
|
|
|
|
}
|
|
|
|
|
2011-06-13 22:17:31 +00:00
|
|
|
___cdist_lib_path()
|
|
|
|
{
|
|
|
|
echo $_
|
|
|
|
}
|
|
|
|
|
2011-03-03 08:43:04 +00:00
|
|
|
|
2011-03-31 13:40:08 +00:00
|
|
|
################################################################################
|
|
|
|
# Cache
|
|
|
|
#
|
|
|
|
__cdist_cache_dir()
|
|
|
|
{
|
|
|
|
cd "${__cdist_local_base_cache_dir}" && pwd -P
|
|
|
|
}
|
|
|
|
|
|
|
|
__cdist_host_cache_dir()
|
|
|
|
{
|
|
|
|
echo "$(__cdist_cache_dir)/$1"
|
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
################################################################################
|
|
|
|
# Object
|
|
|
|
#
|
2011-02-24 16:28:14 +00:00
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
__cdist_object_code()
|
2011-02-07 16:50:25 +00:00
|
|
|
{
|
2011-04-28 12:45:14 +00:00
|
|
|
echo "$(__cdist_object_dir "$1")/${__cdist_name_code}-$2"
|
2011-02-07 16:50:25 +00:00
|
|
|
}
|
|
|
|
|
2011-04-05 20:55:46 +00:00
|
|
|
__cdist_object_prepared()
|
2011-03-30 20:46:49 +00:00
|
|
|
{
|
2011-04-05 20:55:46 +00:00
|
|
|
echo "$(__cdist_object_dir "$1")/${__cdist_name_object_prepared}"
|
2011-03-30 20:46:49 +00:00
|
|
|
}
|
|
|
|
|
2011-03-28 12:55:58 +00:00
|
|
|
__cdist_object_finished()
|
2011-02-22 23:21:11 +00:00
|
|
|
{
|
2011-03-28 12:55:58 +00:00
|
|
|
echo "$(__cdist_object_dir "$1")/${__cdist_name_object_finished}"
|
2011-02-22 23:21:11 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 10:19:05 +00:00
|
|
|
__cdist_object_dir()
|
|
|
|
{
|
2011-03-23 12:38:14 +00:00
|
|
|
echo "$(__cdist_object_base_dir "$1")/${__cdist_name_dot_cdist}"
|
2011-03-23 12:33:26 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 12:38:14 +00:00
|
|
|
__cdist_object_base_dir()
|
2011-03-23 12:33:26 +00:00
|
|
|
{
|
|
|
|
echo "${__cdist_out_object_dir}/$1"
|
2011-03-23 10:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__cdist_object_id_from_object()
|
|
|
|
{
|
|
|
|
echo "${1#*/}"
|
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
# Find objects, remove ./ and /MARKER
|
|
|
|
__cdist_object_list()
|
2011-02-24 15:33:08 +00:00
|
|
|
{
|
2011-03-23 10:12:39 +00:00
|
|
|
local basedir="$1"; shift
|
|
|
|
|
|
|
|
# Use subshell to prevent changing cwd in program
|
|
|
|
(
|
|
|
|
cd "${basedir}"
|
|
|
|
|
2011-03-23 15:39:06 +00:00
|
|
|
find . -name "$__cdist_name_dot_cdist" | \
|
|
|
|
sed -e 's;^./;;' -e "s;/${__cdist_name_dot_cdist}\$;;"
|
2011-03-23 10:12:39 +00:00
|
|
|
)
|
2011-02-16 18:44:04 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
__cdist_object_parameter_dir()
|
2011-02-16 22:04:02 +00:00
|
|
|
{
|
2011-03-23 10:12:39 +00:00
|
|
|
echo "$(__cdist_object_dir "$1")/${__cdist_name_parameter}"
|
2011-03-07 22:55:46 +00:00
|
|
|
}
|
2011-02-16 22:04:02 +00:00
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
__cdist_object_require()
|
2011-03-10 16:41:08 +00:00
|
|
|
{
|
2011-03-23 10:12:39 +00:00
|
|
|
echo "$(__cdist_object_dir "$1")/${__cdist_name_require}"
|
2011-03-10 16:41:08 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 10:30:22 +00:00
|
|
|
__cdist_object_source_name()
|
|
|
|
{
|
|
|
|
echo "$1/${__cdist_name_object_source}"
|
|
|
|
}
|
|
|
|
|
2011-03-23 10:19:05 +00:00
|
|
|
__cdist_object_source()
|
2011-02-23 08:50:30 +00:00
|
|
|
{
|
2011-03-23 10:30:22 +00:00
|
|
|
cat "$(__cdist_object_source_name "$1")"
|
|
|
|
}
|
|
|
|
|
|
|
|
__cdist_object_source_add()
|
|
|
|
{
|
|
|
|
echo "$__cdist_manifest" >> "$(__cdist_object_source_name "$1")"
|
2011-02-23 08:50:30 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 10:19:05 +00:00
|
|
|
__cdist_object_type_explorer_dir()
|
2011-02-16 18:44:04 +00:00
|
|
|
{
|
2011-03-23 10:19:05 +00:00
|
|
|
echo "$(__cdist_object_dir "$1")/${__cdist_name_explorer}"
|
2011-02-24 16:28:14 +00:00
|
|
|
}
|
2011-02-16 18:44:04 +00:00
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
################################################################################
|
|
|
|
# Remote
|
|
|
|
#
|
|
|
|
|
2011-03-26 00:43:55 +00:00
|
|
|
__cdist_remote_object_base_dir()
|
|
|
|
{
|
|
|
|
echo "${__cdist_remote_out_object_dir}/$1"
|
|
|
|
}
|
|
|
|
|
2011-02-24 23:54:49 +00:00
|
|
|
__cdist_remote_object_dir()
|
2011-02-24 20:24:21 +00:00
|
|
|
{
|
2011-03-26 00:43:55 +00:00
|
|
|
echo "$(__cdist_remote_object_base_dir "$1")/${__cdist_name_dot_cdist}"
|
2011-02-24 20:24:21 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 10:19:05 +00:00
|
|
|
__cdist_remote_object_parameter_dir()
|
|
|
|
{
|
|
|
|
echo "$(__cdist_remote_object_dir "$1")/${__cdist_name_parameter}"
|
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
__cdist_remote_object_type_explorer_dir()
|
2011-02-25 00:06:02 +00:00
|
|
|
{
|
2011-03-23 10:12:39 +00:00
|
|
|
echo "$(__cdist_remote_object_dir "$1")/${__cdist_name_explorer}"
|
2011-02-25 00:06:02 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
|
|
|
|
__cdist_remote_type_explorer_dir()
|
2011-03-18 00:31:30 +00:00
|
|
|
{
|
2011-03-23 10:12:39 +00:00
|
|
|
echo "${__cdist_remote_type_dir}/$1/${__cdist_name_explorer}"
|
2011-03-18 00:31:30 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
|
|
|
|
################################################################################
|
2011-05-10 15:11:15 +00:00
|
|
|
# Traps
|
2011-03-23 10:12:39 +00:00
|
|
|
#
|
|
|
|
__cdist_tmp_removal()
|
2011-02-24 20:24:21 +00:00
|
|
|
{
|
2011-03-23 10:12:39 +00:00
|
|
|
rm -rf "${__cdist_tmp_dir}"
|
2011-02-24 20:24:21 +00:00
|
|
|
}
|
|
|
|
|
2011-06-08 19:23:53 +00:00
|
|
|
# Does not work in children, will be called again in every script!
|
|
|
|
# Use only in interactive "front end" scripts
|
2011-06-08 19:19:05 +00:00
|
|
|
__cdist_kill_on_interrupt()
|
2011-05-10 15:11:15 +00:00
|
|
|
{
|
|
|
|
__cdist_tmp_removal
|
2011-06-08 19:19:05 +00:00
|
|
|
kill 0
|
2011-06-08 19:26:13 +00:00
|
|
|
exit 1
|
2011-05-10 15:11:15 +00:00
|
|
|
}
|
|
|
|
|
2011-06-08 19:19:05 +00:00
|
|
|
# Remove tempfiles at normal exit
|
2011-03-23 10:12:39 +00:00
|
|
|
trap __cdist_tmp_removal EXIT
|
2011-06-08 19:19:05 +00:00
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Type
|
|
|
|
#
|
|
|
|
__cdist_type_dir()
|
2011-02-24 16:28:14 +00:00
|
|
|
{
|
2011-03-23 10:12:39 +00:00
|
|
|
echo "${__cdist_type_dir}/$1"
|
2011-02-24 23:54:49 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
__cdist_type_explorer_dir()
|
2011-03-16 14:49:28 +00:00
|
|
|
{
|
2011-03-23 10:12:39 +00:00
|
|
|
echo "${__cdist_type_dir}/$1/${__cdist_name_explorer}"
|
2011-03-16 14:49:28 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
__cdist_type_from_object()
|
2011-02-24 23:54:49 +00:00
|
|
|
{
|
2011-03-23 10:12:39 +00:00
|
|
|
echo "${1%%/*}"
|
2011-02-24 23:54:49 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
__cdist_type_has_explorer()
|
2011-02-24 23:54:49 +00:00
|
|
|
{
|
2011-03-23 10:12:39 +00:00
|
|
|
# We only create output, if there's at least one explorer
|
|
|
|
# and can thus be used as a boolean ;-)
|
|
|
|
if [ -d "$(__cdist_type_explorer_dir "$1")" ]; then
|
|
|
|
ls -1 "$(__cdist_type_explorer_dir "$1")"
|
|
|
|
fi
|
2011-02-16 18:44:04 +00:00
|
|
|
}
|
|
|
|
|
2011-03-29 12:36:35 +00:00
|
|
|
__cdist_type_explorer_pushed()
|
|
|
|
{
|
|
|
|
[ -f "${__cdist_out_type_dir}/${__cdist_name_type_explorer_pushed}" ] \
|
|
|
|
&& grep -q "$1" "${__cdist_out_type_dir}/${__cdist_name_type_explorer_pushed}"
|
|
|
|
}
|
|
|
|
|
|
|
|
__cdist_type_explorer_pushed_add()
|
|
|
|
{
|
|
|
|
[ -d "$__cdist_out_type_dir" ] || mkdir "$__cdist_out_type_dir"
|
|
|
|
echo "$1" >> "${__cdist_out_type_dir}/${__cdist_name_type_explorer_pushed}"
|
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
__cdist_type_gencode()
|
2011-02-16 19:12:29 +00:00
|
|
|
{
|
2011-04-28 12:46:35 +00:00
|
|
|
echo "${__cdist_type_dir}/$1/${__cdist_name_gencode}-$2"
|
2011-02-16 19:12:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 15:33:16 +00:00
|
|
|
__cdist_type_manifest()
|
|
|
|
{
|
|
|
|
echo "${__cdist_type_dir}/$1/${__cdist_name_manifest}"
|
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
__cdist_type_parameter_dir()
|
2011-02-16 21:11:53 +00:00
|
|
|
{
|
2011-03-23 10:12:39 +00:00
|
|
|
echo "$(__cdist_type_dir "$1")/${__cdist_name_parameter}"
|
2011-02-16 21:11:53 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
__cdist_type_parameter_optional()
|
2011-02-22 10:31:37 +00:00
|
|
|
{
|
2011-03-23 10:12:39 +00:00
|
|
|
echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_optional"
|
2011-02-22 10:31:37 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
__cdist_type_parameter_required()
|
2011-02-05 18:32:29 +00:00
|
|
|
{
|
2011-03-23 10:12:39 +00:00
|
|
|
echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_required"
|
2011-02-05 18:32:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 10:12:39 +00:00
|
|
|
__cdist_type_singleton()
|
|
|
|
{
|
|
|
|
echo "${__cdist_type_dir}/$1/${__cdist_name_singleton}"
|
|
|
|
}
|