}
config_load() {
- local file
- case "$1" in
- /*) file="$1";;
- *) file="$UCI_ROOT/etc/config/$1";;
+ local cfg
+ local uci
+ local PACKAGE="$1"
+
+ case "$PACKAGE" in
+ /*) cfg="$PACKAGE"
+ uci=""
+ ;;
+ *) cfg="$UCI_ROOT/etc/config/$PACKAGE"
+ uci="/tmp/.uci/${PACKAGE}"
+ ;;
esac
+
+ [ -e "$cfg" ] || cfg=""
+ [ -e "$uci" ] || uci=""
+
+ # no config
+ [ -z "$cfg" -a -z "$uci" ] && return 1
+
_C=0
export ${NO_EXPORT:+-n} CONFIG_SECTIONS=
export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=0
export ${NO_EXPORT:+-n} CONFIG_SECTION=
-
- [ -e "$file" ] && {
- . $file
- } || return 1
+
+ ${cfg:+. "$cfg"}
+ ${uci:+. "$uci"}
${CONFIG_SECTION:+config_cb}
}
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
uci_load() {
- local PACKAGE="$1"
- config_load "$PACKAGE"
- local PACKAGE_BASE="$(basename "$PACKAGE")"
- [ -f "/tmp/.uci/${PACKAGE_BASE}" ] && {
- . "/tmp/.uci/${PACKAGE_BASE}" 2>/dev/null >/dev/null
- config_cb
- }
+ config_load "$1"
}
uci_apply_defaults() {(