You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.9 KiB
71 lines
1.9 KiB
14 years ago
|
#!/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/>.
|
||
|
#
|
||
|
#
|
||
|
# Wrapper script that generates cconfig from arguments
|
||
|
#
|
||
14 years ago
|
# This script will be called everytime the manifest decides to create
|
||
|
# a new type
|
||
|
#
|
||
14 years ago
|
|
||
|
|
||
|
. cdist-config
|
||
|
|
||
14 years ago
|
[ $# -ge 1 ] || __cdist_usage "<id> <options>"
|
||
|
|
||
14 years ago
|
echo "I am $__cdist_myname and have been called with $@"
|
||
14 years ago
|
|
||
|
id="$1"; shift
|
||
|
|
||
|
# FIXME: find a better definiton of sane (i.e. everything that is a valid filename)
|
||
14 years ago
|
sanechars='[A-Za-z0-9_]'
|
||
14 years ago
|
|
||
14 years ago
|
echo "$id" | grep -q "^${sanechars}*\$" || __cdist_usage "Provide sane id, please"
|
||
14 years ago
|
|
||
14 years ago
|
tid="${__cdist_myname}/${id}"
|
||
|
ddir="${cdist_confdir}/${tid}"
|
||
|
|
||
|
if [ -e "${ddir}" ]; then
|
||
14 years ago
|
# FIXME: add source! $cdist_config_base/source
|
||
14 years ago
|
# FIXME: force $source information to be present from outside!
|
||
14 years ago
|
__cdist_usage "${tid} already exists"
|
||
14 years ago
|
fi
|
||
|
|
||
14 years ago
|
mkdir -p "${ddir}"
|
||
14 years ago
|
|
||
|
while [ $# -gt 0 ]; do
|
||
|
opt="$1"; shift
|
||
|
|
||
|
echo "$opt" | grep -q "^--${sanechars}*\$" || __cdist_usage "Provide sane options"
|
||
|
|
||
14 years ago
|
opt_file="$(echo $opt | sed 's/^--//')"
|
||
14 years ago
|
|
||
14 years ago
|
# FIXME: check for options supported by type - or leave it to the type?
|
||
|
# I guess do it here, so we also check whether
|
||
|
|
||
14 years ago
|
[ $# -ge 1 ] || __cdist_usage "Missing value for $opt"
|
||
|
|
||
|
value="$1"; shift
|
||
|
|
||
14 years ago
|
echo "${value}" > "${ddir}/${opt_file}"
|
||
|
|
||
14 years ago
|
|
||
|
|
||
|
done
|