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
" 0
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
137 # config_get <variable> <section> <option> [<default>]
138 # config_get <section> <option>
141 "") eval echo "\
${CONFIG_${1}_${2}:-\${4}}";;
142 *) eval export ${NO_EXPORT:+-n} -- "${1}=\${CONFIG_${2}_${3}:-\${4}}";;
146 # config_get_bool <variable> <section> <option> [<default>]
149 config_get _tmp
"$2" "$3" "$4"
151 1|on|true|enabled
) _tmp
=1;;
152 0|off|false|disabled
) _tmp
=0;;
155 export ${NO_EXPORT:+-n} "$1=$_tmp"
162 local old_section
="$CONFIG_SECTION"
164 CONFIG_SECTION
="$section"
165 option
"$option" "$value"
166 CONFIG_SECTION
="$old_section"
171 [ "$#" -ge 1 ] && shift
173 [ "$#" -ge 1 ] && shift
174 local section cfgtype
176 [ -z "$CONFIG_SECTIONS" ] && return 0
177 for section
in ${CONFIG_SECTIONS}; do
178 config_get cfgtype
"$section" TYPE
179 [ -n "$type" -a "x$cfgtype" != "x$type" ] && continue
180 eval "$function \"\$section\" \"\$@\""
184 config_list_foreach
() {
185 [ "$#" -ge 3 ] ||
return 0
186 local section
="$1"; shift
187 local option
="$1"; shift
188 local function="$1"; shift
193 config_get len
"${section}" "${option}_LENGTH"
194 [ -z "$len" ] && return 0
195 while [ $c -le "$len" ]; do
196 config_get val
"${section}" "${option}_ITEM$c"
197 eval "$function \"\$val\" \"$@\""
203 [ -d /etc
/modules.d
] && {
205 sed 's/^[^#]/insmod &/' $
* | ash
2>&- ||
:
212 for file in $
(ls $1/*.sh
2>/dev
/null
); do
218 local PART
="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
219 local PREFIX
=/dev
/mtdblock
222 [ -d /dev
/mtdblock
] && PREFIX
=/dev
/mtdblock
/
223 echo "${PART:+$PREFIX$PART}"
226 strtok
() { # <string> { <variable> [<separator>] ... }
233 while [ $# -gt 1 ]; do
236 [ "$tmp" = "$val" ] && break
240 export ${NO_EXPORT:+-n} "$1=$tmp"; count
=$
((count
+1))
244 if [ $# -gt 0 -a -n "$val" ]; then
245 export ${NO_EXPORT:+-n} "$1=$val"; count
=$
((count
+1))
253 local part
="$(find_mtd_part "$1")"
255 echo Partition not found.
258 echo -e "\xde\xad\xc0\xde" | mtd
-qq write - "$1"
261 uci_apply_defaults
() {(
262 cd /etc
/uci-defaults ||
return 0
264 [ -z "$files" ] && return 0
266 for file in $files; do
267 ( .
"./$(basename $file)" ) && rm -f "$file"
272 [ -z "$IPKG_INSTROOT" -a -f /lib
/config
/uci.sh
] && .
/lib
/config
/uci.sh
This page took 0.054131 seconds and 5 git commands to generate.