28bd792010c5391767af2161c27c5dc88cde9b83
2 # Copyright (C) 2006 OpenWrt.org
3 # Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
5 alias debug
=${DEBUG:-:}
17 env
-i ACTION
=$1 INTERFACE
=$2 /sbin
/hotplug-call net
25 eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\""
33 eval "val=\" \${$var} \""
34 [ "${val%% $str *}" != "$val" ]
42 eval "val=\" \${$var} \""
43 val1
="${val%% $remove *}"
44 [ "$val1" = "$val" ] && return
45 val2
="${val##* $remove }"
46 [ "$val2" = "$val" ] && return
47 val
="${val1## } ${val2%% }"
49 eval "export ${NO_EXPORT:+-n} -- \"$var=\$val\""
53 [ -n "$IPKG_INSTROOT" ] && return 0
58 config_cb
() { return 0; }
59 option_cb
() { return 0; }
60 list_cb
() { return 0; }
72 export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS
=$
(($CONFIG_NUM_SECTIONS + 1))
73 name
="${name:-cfg$CONFIG_NUM_SECTIONS}"
74 append CONFIG_SECTIONS
"$name"
75 [ -n "$NO_CALLBACK" ] || config_cb
"$cfgtype" "$name"
76 export ${NO_EXPORT:+-n} CONFIG_SECTION
="$name"
77 export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_TYPE=$cfgtype"
81 local varname
="$1"; shift
84 export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_${varname}=$value"
85 [ -n "$NO_CALLBACK" ] || option_cb "$varname" "$
*"
89 local varname="$1"; shift
93 config_get len "$CONFIG_SECTION" "${varname}_LENGTH
"
94 len="$
((${len:-0} + 1))"
95 config_set "$CONFIG_SECTION" "${varname}_ITEM
$len" "$value"
96 config_set "$CONFIG_SECTION" "${varname}_LENGTH
" "$len"
97 append "CONFIG_
${CONFIG_SECTION}_
${varname}" "$value" "$LIST_SEP"
98 list_cb "$varname" "$
*"
107 [ -n "$OLD" -a -n "$NEW" ] || return
108 for oldvar in `set | grep ^CONFIG_${OLD}_ | \
109 sed -e 's/\(.*\)=.*$/\1/'` ; do
110 newvar="CONFIG_
${NEW}_${oldvar##CONFIG_${OLD}_}"
111 eval "export ${NO_EXPORT:+-n} \"$newvar=\
${$oldvar}\""
114 export ${NO_EXPORT:+-n} CONFIG_SECTIONS="$
(echo " $CONFIG_SECTIONS " |
sed -e "s, $OLD , $NEW ,")"
116 [ "$CONFIG_SECTION" = "$OLD" ] && export ${NO_EXPORT:+-n} CONFIG_SECTION="$NEW"
120 config_set "$1" "$2" ""
127 list_remove CONFIG_SECTIONS "$SECTION"
128 export ${NO_EXPORT:+-n} CONFIG_SECTIONS="${SECTION:+$CONFIG_SECTIONS}"
130 for oldvar in `set | grep ^CONFIG_${SECTION:+${SECTION}_} | \
131 sed -e 's/\(.*\)=.*$/\1/'` ; do
138 "") eval "echo \"\
${CONFIG_${1}_${2}}\"";;
139 *) eval "export ${NO_EXPORT:+-n} -- \"$1=\${CONFIG_${2}_${3}}\"";;
143 # config_get_bool <variable> <section> <option> [<default>]
146 config_get "_tmp
" "$2" "$3"
148 1|on|true|enabled) export ${NO_EXPORT:+-n} "$1=1";;
149 0|off|false|disabled) export ${NO_EXPORT:+-n} "$1=0";;
158 local old_section="$CONFIG_SECTION"
160 CONFIG_SECTION="$section"
161 option "$option" "$value"
162 CONFIG_SECTION="$old_section"
167 [ "$#" -ge 1 ] && shift
169 [ "$#" -ge 1 ] && shift
170 local section cfgtype
172 [ -z "$CONFIG_SECTIONS" ] && return 0
173 for section in ${CONFIG_SECTIONS}; do
174 config_get cfgtype "$section" TYPE
175 [ -n "$type" -a "x
$cfgtype" != "x
$type" ] && continue
176 eval "$function \"\
$section\" \"\$@
\""
180 config_list_foreach() {
181 [ "$#" -ge 3 ] || return 0
182 local section="$1"; shift
183 local option="$1"; shift
184 local function="$1"; shift
189 config_get len "${section}" "${option}_LENGTH
"
190 [ -z "$len" ] && return 0
191 while [ $c -le "$len" ]; do
192 config_get val "${section}" "${option}_ITEM
$c"
193 eval "$function \"\
$val\" \"$@
\""
199 [ -d /etc/modules.d ] && {
201 sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
208 for file in $(ls $1/*.sh 2>/dev/null); do
214 local PART="$
(grep "\"$1\"" /proc
/mtd |
awk -F: '{print $1}')"
215 local PREFIX=/dev/mtdblock
218 [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
219 echo "${PART:+$PREFIX$PART}"
222 strtok() { # <string> { <variable> [<separator>] ... }
229 while [ $# -gt 1 ]; do
232 [ "$tmp" = "$val" ] && break
236 export ${NO_EXPORT:+-n} "$1=$tmp"; count=$((count+1))
240 if [ $# -gt 0 -a -n "$val" ]; then
241 export ${NO_EXPORT:+-n} "$1=$val"; count=$((count+1))
249 local part="$
(find_mtd_part
"$1")"
251 echo Partition not found.
254 echo -e "\xde\xad\xc0\xde" | mtd -qq write - "$1"
257 uci_apply_defaults() {(
258 cd /etc/uci-defaults || return 0
260 [ -z "$files" ] && return 0
262 for file in $files; do
263 ( . ".
/$
(basename $file)" ) && rm -f "$file"
268 [ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh
This page took 0.057205 seconds and 3 git commands to generate.