2 # Copyright (C) 2006 OpenWrt.org
3 # Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
5 alias debug
=${DEBUG:-:}
6 alias mount
='busybox mount'
18 env
-i ACTION
=$1 INTERFACE
=$2 /sbin
/hotplug-call net
26 eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\""
34 eval "val=\" \${$var} \""
35 [ "${val%% $str *}" != "$val" ]
43 eval "val=\" \${$var} \""
44 val1
="${val%% $remove *}"
45 [ "$val1" = "$val" ] && return
46 val2
="${val##* $remove }"
47 [ "$val2" = "$val" ] && return
48 val
="${val1## } ${val2%% }"
50 eval "export ${NO_EXPORT:+-n} -- \"$var=\$val\""
54 [ -n "$IPKG_INSTROOT" ] && return 0
59 config_cb
() { return 0; }
60 option_cb
() { return 0; }
61 list_cb
() { return 0; }
73 export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS
=$
(($CONFIG_NUM_SECTIONS + 1))
74 name
="${name:-cfg$CONFIG_NUM_SECTIONS}"
75 append CONFIG_SECTIONS
"$name"
76 [ -n "$NO_CALLBACK" ] || config_cb
"$cfgtype" "$name"
77 export ${NO_EXPORT:+-n} CONFIG_SECTION
="$name"
78 export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_TYPE=$cfgtype"
82 local varname
="$1"; shift
85 export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_${varname}=$value"
86 [ -n "$NO_CALLBACK" ] || option_cb "$varname" "$
*"
90 local varname="$1"; shift
94 config_get len "$CONFIG_SECTION" "${varname}_LENGTH
"
95 len="$
((${len:-0} + 1))"
96 config_set "$CONFIG_SECTION" "${varname}_ITEM
$len" "$value"
97 config_set "$CONFIG_SECTION" "${varname}_LENGTH
" "$len"
98 append "CONFIG_
${CONFIG_SECTION}_
${varname}" "$value" "$LIST_SEP"
99 list_cb "$varname" "$
*"
108 [ -n "$OLD" -a -n "$NEW" ] || return
109 for oldvar in `set | grep ^CONFIG_${OLD}_ | \
110 sed -e 's/\(.*\)=.*$/\1/'` ; do
111 newvar="CONFIG_
${NEW}_${oldvar##CONFIG_${OLD}_}"
112 eval "export ${NO_EXPORT:+-n} \"$newvar=\
${$oldvar}\""
115 export ${NO_EXPORT:+-n} CONFIG_SECTIONS="$
(echo " $CONFIG_SECTIONS " |
sed -e "s, $OLD , $NEW ,")"
117 [ "$CONFIG_SECTION" = "$OLD" ] && export ${NO_EXPORT:+-n} CONFIG_SECTION="$NEW"
121 config_set "$1" "$2" ""
128 list_remove CONFIG_SECTIONS "$SECTION"
129 export ${NO_EXPORT:+-n} CONFIG_SECTIONS="${SECTION:+$CONFIG_SECTIONS}"
131 for oldvar in `set | grep ^CONFIG_${SECTION:+${SECTION}_} | \
132 sed -e 's/\(.*\)=.*$/\1/'` ; do
139 "") eval "echo \"\
${CONFIG_${1}_${2}}\"";;
140 *) eval "export ${NO_EXPORT:+-n} -- \"$1=\${CONFIG_${2}_${3}}\"";;
144 # config_get_bool <variable> <section> <option> [<default>]
147 config_get "_tmp
" "$2" "$3"
149 1|on|true|enabled) export ${NO_EXPORT:+-n} "$1=1";;
150 0|off|false|disabled) export ${NO_EXPORT:+-n} "$1=0";;
159 local old_section="$CONFIG_SECTION"
161 CONFIG_SECTION="$section"
162 option "$option" "$value"
163 CONFIG_SECTION="$old_section"
168 [ "$#" -ge 1 ] && shift
170 [ "$#" -ge 1 ] && shift
171 local section cfgtype
173 [ -z "$CONFIG_SECTIONS" ] && return 0
174 for section in ${CONFIG_SECTIONS}; do
175 config_get cfgtype "$section" TYPE
176 [ -n "$type" -a "x
$cfgtype" != "x
$type" ] && continue
177 eval "$function \"\
$section\" \"\$@
\""
181 config_list_foreach() {
182 [ "$#" -ge 3 ] || return 0
183 local section="$1"; shift
184 local option="$1"; shift
185 local function="$1"; shift
190 config_get len "${section}" "${option}_LENGTH
"
191 [ -z "$len" ] && return 0
192 while [ $c -le "$len" ]; do
193 config_get val "${section}" "${option}_ITEM
$c"
194 eval "$function \"\
$val\" \"$@
\""
200 [ -d /etc/modules.d ] && {
202 sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
209 for file in $(ls $1/*.sh 2>/dev/null); do
215 local PART="$
(grep "\"$1\"" /proc
/mtd |
awk -F: '{print $1}')"
216 local PREFIX=/dev/mtdblock
219 [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
220 echo "${PART:+$PREFIX$PART}"
223 strtok() { # <string> { <variable> [<separator>] ... }
230 while [ $# -gt 1 ]; do
233 [ "$tmp" = "$val" ] && break
237 export ${NO_EXPORT:+-n} "$1=$tmp"; count=$((count+1))
241 if [ $# -gt 0 -a -n "$val" ]; then
242 export ${NO_EXPORT:+-n} "$1=$val"; count=$((count+1))
250 local part="$
(find_mtd_part
"$1")"
252 echo Partition not found.
255 echo -e "\xde\xad\xc0\xde" | mtd -qq write - "$1"
258 uci_apply_defaults() {(
259 cd /etc/uci-defaults || return 0
261 [ -z "$files" ] && return 0
263 for file in $files; do
264 ( . ".
/$
(basename $file)" ) && rm -f "$file"
269 [ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh
This page took 0.055961 seconds and 5 git commands to generate.