summaryrefslogtreecommitdiff
path: root/openwrt/package/base-files/default/etc/functions.sh
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2006-06-25 15:32:30 +0000
committerFelix Fietkau <nbd@openwrt.org>2006-06-25 15:32:30 +0000
commit292fb9eaeeb53a7cb60a0cecb7e46f11d8626b91 (patch)
treec8dc167f67054d4e6c866ff703767066d76b6d7b /openwrt/package/base-files/default/etc/functions.sh
parent9813eb4983b64150d3e0f7f3593e6850e559c576 (diff)
downloadmtk-20170518-292fb9eaeeb53a7cb60a0cecb7e46f11d8626b91.zip
mtk-20170518-292fb9eaeeb53a7cb60a0cecb7e46f11d8626b91.tar.gz
mtk-20170518-292fb9eaeeb53a7cb60a0cecb7e46f11d8626b91.tar.bz2
fixes for common config functions
SVN-Revision: 4071
Diffstat (limited to 'openwrt/package/base-files/default/etc/functions.sh')
-rwxr-xr-xopenwrt/package/base-files/default/etc/functions.sh42
1 files changed, 27 insertions, 15 deletions
diff --git a/openwrt/package/base-files/default/etc/functions.sh b/openwrt/package/base-files/default/etc/functions.sh
index fbb5a16..e87515d 100755
--- a/openwrt/package/base-files/default/etc/functions.sh
+++ b/openwrt/package/base-files/default/etc/functions.sh
@@ -5,6 +5,8 @@ alias debug=${DEBUG:-:}
N="
"
+_C=0
+
# valid interface?
if_valid () (
ifconfig "$1" >&- 2>&- ||
@@ -23,18 +25,24 @@ append() {
eval "export ${var}=\"\${${var}:+\${${var}}${value:+$sep}}$value\""
}
-config_cb() {
- return 0
-}
-option_cb() {
- return 0
+reset_cb() {
+ config_cb() {
+ return 0
+ }
+ option_cb() {
+ return 0
+ }
}
+reset_cb
config () {
- config_cb "$@"
- _C=$((${_C:-0} + 1))
- export CONFIG_SECTION="${2:-cfg${_C}}"
- export CONFIG_${CONFIG_SECTION}_TYPE="$1"
+ local type="$1"
+ local name="$2"
+ _C=$(($_C + 1))
+ name="${name:-cfg${_C}}"
+ config_cb "$type" "$name"
+ export CONFIG_SECTION="$name"
+ export CONFIG_${CONFIG_SECTION}_TYPE="$type"
}
option () {
@@ -53,12 +61,16 @@ config_clear() {
}
config_load() {
- local CD=""
- if [ \! -e "$1" -a -e "/etc/config/$1" ]; then
- cd /etc/config && local CD=1
- fi
- [ -e "$1" ] && . $1
- ${CD:+cd - >/dev/null}
+ local DIR="./"
+ _C=0
+ [ \! -e "$1" -a -e "/etc/config/$1" ] && {
+ DIR="/etc/config/"
+ }
+ [ -e "$DIR$1" ] && {
+ CONFIG_FILENAME="$DIR$1"
+ . ${CONFIG_FILENAME}
+ } || return 1
+ ${CD:+cd -} >/dev/null
${CONFIG_SECTION:+config_cb}
}