e06c0824dc
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
57 lines
1.5 KiB
Bash
Executable file
57 lines
1.5 KiB
Bash
Executable file
#!/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
|
|
#
|
|
|
|
|
|
. cdist-config
|
|
|
|
[ $# -ge 1 ] || __cdist_usage "<id> <options>"
|
|
|
|
echo "I am $__cdist_myname and have been called with $@"
|
|
|
|
id="$1"; shift
|
|
|
|
# FIXME: find a better definiton of sane (i.e. everything that is a valid filename)
|
|
sanechars='[A-Za-z0-9_]'
|
|
|
|
echo "$id" | grep -q "^${sanechars}*\$" || __cdist_usage "Provide sane id, please"
|
|
|
|
if [ -e "${cdist_confdir}/${__cdist_myname}/${id}" ]; then
|
|
# FIXME: add source! $cdist_config_base/source
|
|
__cdist_usage "${__cdist_myname}/${id} already exists"
|
|
fi
|
|
|
|
mkdir -p "${cdist_confdir}/${__cdist_myname}/${id}"
|
|
|
|
while [ $# -gt 0 ]; do
|
|
opt="$1"; shift
|
|
|
|
echo "$opt" | grep -q "^--${sanechars}*\$" || __cdist_usage "Provide sane options"
|
|
|
|
|
|
[ $# -ge 1 ] || __cdist_usage "Missing value for $opt"
|
|
|
|
value="$1"; shift
|
|
|
|
|
|
|
|
done
|