projects
/
openwrt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixes for common config functions
[openwrt.git]
/
package
/
base-files
/
default
/
etc
/
functions.sh
diff --git
a/package/base-files/default/etc/functions.sh
b/package/base-files/default/etc/functions.sh
index
d54a346
..
e87515d
100755
(executable)
--- a/
package/base-files/default/etc/functions.sh
+++ b/
package/base-files/default/etc/functions.sh
@@
-1,6
+1,12
@@
#!/bin/sh
alias debug=${DEBUG:-:}
#!/bin/sh
alias debug=${DEBUG:-:}
+# newline
+N="
+"
+
+_C=0
+
# valid interface?
if_valid () (
ifconfig "$1" >&- 2>&- ||
# valid interface?
if_valid () (
ifconfig "$1" >&- 2>&- ||
@@
-12,18
+18,31
@@
hotplug_dev() {
env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug net
}
env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug net
}
-config_cb() {
- return 0
+append() {
+ local var="$1"
+ local value="$2"
+ local sep="${3:- }"
+ eval "export ${var}=\"\${${var}:+\${${var}}${value:+$sep}}$value\""
}
}
-option_cb() {
- return 0
+
+reset_cb() {
+ config_cb() {
+ return 0
+ }
+ option_cb() {
+ return 0
+ }
}
}
+reset_cb
config () {
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 () {
}
option () {
@@
-42,12
+61,16
@@
config_clear() {
}
config_load() {
}
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}
}
${CONFIG_SECTION:+config_cb}
}
This page took
0.025717 seconds
and
4
git commands to generate.