aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/etc
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2006-12-20 04:15:13 +0000
committerFelix Fietkau <nbd@openwrt.org>2006-12-20 04:15:13 +0000
commitb102a2846f649aa418b614b77288f9d257c4aea5 (patch)
treef4bb5642780c5c8d9f98bc31faff5415e84f86f8 /package/base-files/files/etc
parentd7f1af3daf5541eb37bb7b30b330bca6b6e7a50e (diff)
downloadmaster-187ad058-b102a2846f649aa418b614b77288f9d257c4aea5.tar.gz
master-187ad058-b102a2846f649aa418b614b77288f9d257c4aea5.tar.bz2
master-187ad058-b102a2846f649aa418b614b77288f9d257c4aea5.zip
add a variable to keep track of the list of sections when loading uci config files. add a function to iterate through sections
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@5870 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/base-files/files/etc')
-rwxr-xr-xpackage/base-files/files/etc/functions.sh25
1 files changed, 21 insertions, 4 deletions
diff --git a/package/base-files/files/etc/functions.sh b/package/base-files/files/etc/functions.sh
index 0f3618e7fd..cc7b70e511 100755
--- a/package/base-files/files/etc/functions.sh
+++ b/package/base-files/files/etc/functions.sh
@@ -31,9 +31,10 @@ reset_cb
config () {
local cfgtype="$1"
local name="$2"
-
- _C=$((_C + 1))
- name="${name:-cfg${_C}}"
+
+ CONFIG_NUM_SECTIONS=$(($CONFIG_NUM_SECTIONS + 1))
+ name="${name:-cfg$CONFIG_NUM_SECTIONS}"
+ append CONFIG_SECTIONS "$name"
config_cb "$cfgtype" "$name"
CONFIG_SECTION="$name"
export -n "CONFIG_${CONFIG_SECTION}_TYPE=$cfgtype"
@@ -60,6 +61,7 @@ config_rename() {
eval "export -n \"$newvar=\${$oldvar}\""
unset "$oldvar"
done
+ CONFIG_SECTIONS="$(echo " $CONFIG_SECTIONS " | sed -e "s, $OLD , $NEW ,")"
[ "$CONFIG_SECTION" = "$OLD" ] && CONFIG_SECTION="$NEW"
}
@@ -72,7 +74,10 @@ config_clear() {
local SECTION="$1"
local oldvar
- for oldvar in `set | grep ^CONFIG_${SECTION}_ | \
+ CONFIG_SECTIONS="$(echo " $CONFIG_SECTIONS " | sed -e "s, $OLD , ,")"
+ CONFIG_SECTIONS="${SECTION:+$CONFIG_SECTIONS}"
+
+ for oldvar in `set | grep ^CONFIG_${SECTION:+$SECTION_} | \
sed -e 's/\(.*\)=.*$/\1/'` ; do
unset $oldvar
done
@@ -81,6 +86,8 @@ config_clear() {
config_load() {
local file="/etc/config/$1"
_C=0
+ CONFIG_SECTIONS=
+ CONFIG_NUM_SECTIONS=0
CONFIG_SECTION=
[ -e "$file" ] && {
@@ -104,6 +111,16 @@ config_set() {
export -n "CONFIG_${section}_${option}=$value"
}
+config_foreach() {
+ local function="$1"
+ local section
+
+ [ -z "$CONFIG_SECTIONS" ] && return 0
+ for section in ${CONFIG_SECTIONS}; do
+ eval "$function \"\$section\""
+ done
+}
+
load_modules() {
cd /etc/modules.d
sed 's/^[^#]/insmod &/' $* | ash 2>&- || :