cdist/bin/cdist-config

125 lines
3.5 KiB
Text
Raw Normal View History

#!/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/>.
#
#
# Print configuration directories - helper for all other scripts
#
# Values can be overriden from outside, so you can
# customise paths as you like (for distributors, geeks and hackers)
# Names
: ${__cdist_name_bin:=bin}
: ${__cdist_name_cache:=cache}
: ${__cdist_name_explorer:=explorers}
: ${__cdist_name_host:=hosts}
: ${__cdist_name_init:=init}
: ${__cdist_name_object:=objects}
: ${__cdist_name_type:=types}
# Base
: ${__cdist_config:=/etc/cdist}
: ${__cdist_explorer_dir:=$__cdist_config/$__cdist_name_explorer}
: ${__cdist_manifest_dir:=$__cdist_config/manifests}
: ${__cdist_manifest_init:=$__cdist_manifest_dir/$__cdist_name_init}
: ${__cdist_type_dir:=$__cdist_config/$__cdist_name_type}
# Cache
: ${__cdist_cache_dir:=$__cdist_config/cache}
: ${__cdist_cache_hosts:=$__cdist_cache_dir/$__cdist_name_host}
: ${__cdist_cache_bin:=$__cdist_cache_dir/$__cdist_name_bin}
# Remote
: ${__cdist_remote_base_dir:=/var/lib/cdist}
: ${__cdist_remote_explorer_dir:=$__cdist_remote_base_dir/$__cdist_name_explorer}
export __cdist_remote_explorer_dir
: ${__cdist_remote_cache_dir:=$__cdist_remote_base_dir/$__cdist_name_cache}
: ${__cdist_remote_cache_explorer:=$__cdist_remote_cache_dir/$__cdist_name_explorer}
export __cdist_remote_cache_explorer
: ${__cdist_remote_cache_bin:=$__cdist_remote_base_dir/$__cdist_name_bin}
# Tempfiles need to be recreated for each individual script, unshared!
__cdist_tmp_dir=$(mktemp -d "/tmp/cdist.XXXXXXXXXXXX")
export __cdist_tmp_dir
__cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX")
export __cdist_tmp_file
################################################################################
# cconf standard vars prefixed with cdist
__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"
################################################################################
# Other constants
# Used for generating binaries in cdist-build-bin
__cdist_bin_prefix="__"
# Used for IDs
__cdist_sane_regexp='[A-Za-z0-9]*[-A-Za-z0-9_]*'
# File that contains source of a specific object creation
__cdist_object_source=".source"
# Mark object finished
__cdist_object_finished=".done"
################################################################################
# Function list
#
__cdist_debug_echo()
{
if [ "$__cdist_debug" ]; then
echo "Debug: $@"
fi
}
__cdist_exit_err()
{
echo "$@"
exit 1
}
__cdist_usage()
{
__cdist_exit_err "$__cdist_myname: $@"
}
__cdist_cache_host()
{
echo "${__cdist_cache_hosts}/${__cdist_target_host}"
}
__cdist_tmp_removal()
{
rm -rf "${__cdist_tmp_dir}"
}
################################################################################
# Trap for tmp removal
#
trap __cdist_tmp_removal EXIT