cleanup cdist_tree_wrapper
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
f7f687995b
commit
3ead0e5912
2 changed files with 18 additions and 14 deletions
|
@ -58,6 +58,9 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname"
|
|||
# Used for generating binaries in cdist-build-bin
|
||||
__cdist_bin_prefix="__"
|
||||
|
||||
# Used for IDs
|
||||
__cdist_sane_chars='[A-Za-z0-9_]'
|
||||
|
||||
################################################################################
|
||||
# Function list
|
||||
#
|
||||
|
@ -79,6 +82,11 @@ __cdist_usage()
|
|||
__cdist_exit_err "$__cdist_myname: $@"
|
||||
}
|
||||
|
||||
__cdist_cache_host()
|
||||
{
|
||||
echo "${__cdist_cache_hosts}/${__cdist_target_host}"
|
||||
}
|
||||
|
||||
|
||||
#set -e
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2010 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
@ -24,35 +24,31 @@
|
|||
# a new type
|
||||
#
|
||||
|
||||
|
||||
. cdist-config
|
||||
|
||||
[ $# -ge 1 ] || __cdist_usage "<id> <options>"
|
||||
|
||||
echo "I am $__cdist_myname and have been called with $@"
|
||||
|
||||
id="$1"; shift
|
||||
__cdist_id="$1"; shift
|
||||
|
||||
# FIXME: find a better definiton of sane (i.e. everything that is a valid filename)
|
||||
sanechars='[A-Za-z0-9_]'
|
||||
echo "$__cdist_id" | grep -q "^${__cdist_sane_chars}*\$" || __cdist_usage "Provide sane id, please"
|
||||
|
||||
echo "$id" | grep -q "^${sanechars}*\$" || __cdist_usage "Provide sane id, please"
|
||||
__cdist_tid="${__cdist_myname}/${__cdist_id}"
|
||||
__cdist_ddir="$(__cdist_cache_host)/${__cdist_tid}"
|
||||
|
||||
tid="${__cdist_myname}/${id}"
|
||||
ddir="${cdist_confdir}/${tid}"
|
||||
|
||||
if [ -e "${ddir}" ]; then
|
||||
if [ -e "${__cdist_ddir}" ]; then
|
||||
# FIXME: add source! $cdist_config_base/source
|
||||
# FIXME: force $source information to be present from outside!
|
||||
__cdist_usage "${tid} already exists"
|
||||
__cdist_usage "${__cdist_tid} already exists"
|
||||
fi
|
||||
|
||||
mkdir -p "${ddir}"
|
||||
mkdir -p "${__cdist_ddir}"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
opt="$1"; shift
|
||||
|
||||
echo "$opt" | grep -q "^--${sanechars}*\$" || __cdist_usage "Provide sane options"
|
||||
echo "$opt" | grep -q "^--${__cdist_sane_chars}*\$" || __cdist_usage "Provide sane options"
|
||||
|
||||
opt_file="$(echo $opt | sed 's/^--//')"
|
||||
|
||||
|
@ -63,7 +59,7 @@ while [ $# -gt 0 ]; do
|
|||
|
||||
value="$1"; shift
|
||||
|
||||
echo "${value}" > "${ddir}/${opt_file}"
|
||||
echo "${value}" > "${__cdist_ddir}/${opt_file}"
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue