1 # Shell script defining validating configuration macros
3 # Copyright (C) 2006 by Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
4 # Copyright (C) 2007 by Felix Fietkau <nbd@openwrt.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 export | grep 'CONFIG_' | cat - "$@" | awk \
23 -f $UCI_ROOT/lib/config/validate_config.awk \
24 -f $UCI_ROOT/lib/config/parse_spec.awk \
25 -f $UCI_ROOT/lib/config/validate_spec.awk
28 validate_config_cb () {
32 [ -n "${CONFIG_SECTION}" ] || return 0
34 config_get TYPE ${CONFIG_SECTION} TYPE
35 [ -n "$TYPE" ] || return 0
37 if type validate_${PACKAGE}_${TYPE} >/dev/null 2>&1; then
38 validate_${PACKAGE}_${TYPE}
41 if [ -f $UCI_ROOT/lib/config/specs/${PACKAGE}.spec ]; then
42 # no special defined, use default one
43 validate_spec $UCI_ROOT/lib/config/specs/${PACKAGE}.spec
48 VALIDATE_RES="${VALIDATE_RES:-$res}"
56 [ -z "${PACKAGE}" ] && {
57 echo "Error: no package defined"
63 validate_config_cb "$@"
66 if [ -n "$FILE" ]; then
73 return ${VALIDATE_RES:-0}