migrate more stuff from cdist-config to core/

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-06-17 12:34:40 +02:00
parent f3a88ef98d
commit c474317a6a
4 changed files with 90 additions and 24 deletions

View file

@ -162,30 +162,6 @@ for __cdist_lib in $__cdist_core_dir/*; do
. "$__cdist_lib"
done
__cdist_exec_fail_on_error()
{
set +e
sh -e "$@"
if [ "$?" -ne 0 ]; then
__cdist_echo error "$1 exited non-zero"
__cdist_echo warn "Faulty code:"
cat "$1"
__cdist_exit_err "Aborting due to non-zero exit code."
fi
}
__cdist_exit_err()
{
__cdist_echo error "$@"
exit 1
}
__cdist_usage()
{
__cdist_exit_err "$__cdist_myname: $@"
}
___cdist_lib_path()
{
echo $_

35
core/__cdist_exec_fail_on_error Executable file
View file

@ -0,0 +1,35 @@
#!/bin/sh
#
# 2011 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/>.
#
#
# Exit if an error occurs
#
__cdist_exec_fail_on_error()
{
set +e
sh -e "$@"
if [ "$?" -ne 0 ]; then
__cdist_echo error "$1 exited non-zero"
__cdist_echo warn "Faulty code:"
cat "$1"
__cdist_exit_err "Aborting due to non-zero exit code."
fi
set -e
}

28
core/__cdist_exit_err Executable file
View file

@ -0,0 +1,28 @@
#!/bin/sh
#
# 2011 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 error and exit (perror() alike)
#
__cdist_exit_err()
{
__cdist_echo error "$@"
exit 1
}

27
core/__cdist_usage Executable file
View file

@ -0,0 +1,27 @@
#!/bin/sh
#
# 2011 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 error and exit (perror() alike)
#
__cdist_usage()
{
__cdist_exit_err "$__cdist_myname: $@"
}