1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2025-01-12 02:30:15 +02:00

fixes for common config functions

git-svn-id: svn://svn.openwrt.org/openwrt/branches/buildroot-ng/openwrt@4071 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nbd 2006-06-25 15:32:30 +00:00
parent 542f51dc8a
commit ffbd3e6165

View File

@ -5,6 +5,8 @@ alias debug=${DEBUG:-:}
N=" N="
" "
_C=0
# valid interface? # valid interface?
if_valid () ( if_valid () (
ifconfig "$1" >&- 2>&- || ifconfig "$1" >&- 2>&- ||
@ -23,18 +25,24 @@ append() {
eval "export ${var}=\"\${${var}:+\${${var}}${value:+$sep}}$value\"" eval "export ${var}=\"\${${var}:+\${${var}}${value:+$sep}}$value\""
} }
config_cb() { reset_cb() {
return 0 config_cb() {
} return 0
option_cb() { }
return 0 option_cb() {
return 0
}
} }
reset_cb
config () { config () {
config_cb "$@" local type="$1"
_C=$((${_C:-0} + 1)) local name="$2"
export CONFIG_SECTION="${2:-cfg${_C}}" _C=$(($_C + 1))
export CONFIG_${CONFIG_SECTION}_TYPE="$1" name="${name:-cfg${_C}}"
config_cb "$type" "$name"
export CONFIG_SECTION="$name"
export CONFIG_${CONFIG_SECTION}_TYPE="$type"
} }
option () { option () {
@ -53,12 +61,16 @@ config_clear() {
} }
config_load() { config_load() {
local CD="" local DIR="./"
if [ \! -e "$1" -a -e "/etc/config/$1" ]; then _C=0
cd /etc/config && local CD=1 [ \! -e "$1" -a -e "/etc/config/$1" ] && {
fi DIR="/etc/config/"
[ -e "$1" ] && . $1 }
${CD:+cd - >/dev/null} [ -e "$DIR$1" ] && {
CONFIG_FILENAME="$DIR$1"
. ${CONFIG_FILENAME}
} || return 1
${CD:+cd -} >/dev/null
${CONFIG_SECTION:+config_cb} ${CONFIG_SECTION:+config_cb}
} }