2 # Copyright (C) 2006 OpenWrt.org
3 # Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
23 env
-i ACTION
=$1 INTERFACE
=$2 /sbin
/hotplug-call net
31 eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\""
39 eval "val=\" \${$var} \""
40 [ "${val%% $str *}" != "$val" ]
48 eval "val=\" \${$var} \""
49 val1
="${val%% $remove *}"
50 [ "$val1" = "$val" ] && return
51 val2
="${val##* $remove }"
52 [ "$val2" = "$val" ] && return
53 val
="${val1## } ${val2%% }"
55 eval "export ${NO_EXPORT:+-n} -- \"$var=\$val\""
59 [ -n "$IPKG_INSTROOT" ] && return 0
64 config_cb
() { return 0; }
65 option_cb
() { return 0; }
66 list_cb
() { return 0; }
78 export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS
=$
(($CONFIG_NUM_SECTIONS + 1))
79 name
="${name:-cfg$CONFIG_NUM_SECTIONS}"
80 append CONFIG_SECTIONS
"$name"
81 [ -n "$NO_CALLBACK" ] || config_cb
"$cfgtype" "$name"
82 export ${NO_EXPORT:+-n} CONFIG_SECTION
="$name"
83 export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_TYPE=$cfgtype"
87 local varname
="$1"; shift
90 export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_${varname}=$value"
91 [ -n "$NO_CALLBACK" ] || option_cb "$varname" "$
*"
95 local varname="$1"; shift
99 config_get len "$CONFIG_SECTION" "${varname}_LENGTH
" 0
101 config_set "$CONFIG_SECTION" "${varname}_ITEM
$len" "$value"
102 config_set "$CONFIG_SECTION" "${varname}_LENGTH
" "$len"
103 append "CONFIG_
${CONFIG_SECTION}_
${varname}" "$value" "$LIST_SEP"
104 list_cb "$varname" "$
*"
113 [ -n "$OLD" -a -n "$NEW" ] || return
114 for oldvar in `set | grep ^CONFIG_${OLD}_ | \
115 sed -e 's/\(.*\)=.*$/\1/'` ; do
116 newvar="CONFIG_
${NEW}_${oldvar##CONFIG_${OLD}_}"
117 eval "export ${NO_EXPORT:+-n} \"$newvar=\
${$oldvar}\""
120 export ${NO_EXPORT:+-n} CONFIG_SECTIONS="$
(echo " $CONFIG_SECTIONS " |
sed -e "s, $OLD , $NEW ,")"
122 [ "$CONFIG_SECTION" = "$OLD" ] && export ${NO_EXPORT:+-n} CONFIG_SECTION="$NEW"
126 config_set "$1" "$2" ""
133 list_remove CONFIG_SECTIONS "$SECTION"
134 export ${NO_EXPORT:+-n} CONFIG_SECTIONS="${SECTION:+$CONFIG_SECTIONS}"
136 for oldvar in `set | grep ^CONFIG_${SECTION:+${SECTION}_} | \
137 sed -e 's/\(.*\)=.*$/\1/'` ; do
142 # config_get <variable> <section> <option> [<default>]
143 # config_get <section> <option>
146 "") eval echo "\
${CONFIG_${1}_${2}:-\${4}}";;
147 *) eval export ${NO_EXPORT:+-n} -- "${1}=\${CONFIG_${2}_${3}:-\${4}}";;
151 # config_get_bool <variable> <section> <option> [<default>]
154 config_get _tmp
"$2" "$3" "$4"
156 1|on|true|enabled
) _tmp
=1;;
157 0|off|false|disabled
) _tmp
=0;;
160 export ${NO_EXPORT:+-n} "$1=$_tmp"
167 local old_section
="$CONFIG_SECTION"
169 CONFIG_SECTION
="$section"
170 option
"$option" "$value"
171 CONFIG_SECTION
="$old_section"
176 [ "$#" -ge 1 ] && shift
178 [ "$#" -ge 1 ] && shift
179 local section cfgtype
181 [ -z "$CONFIG_SECTIONS" ] && return 0
182 for section
in ${CONFIG_SECTIONS}; do
183 config_get cfgtype
"$section" TYPE
184 [ -n "$type" -a "x$cfgtype" != "x$type" ] && continue
185 eval "$function \"\$section\" \"\$@\""
189 config_list_foreach
() {
190 [ "$#" -ge 3 ] ||
return 0
191 local section
="$1"; shift
192 local option
="$1"; shift
193 local function="$1"; shift
198 config_get len
"${section}" "${option}_LENGTH"
199 [ -z "$len" ] && return 0
200 while [ $c -le "$len" ]; do
201 config_get val
"${section}" "${option}_ITEM$c"
202 eval "$function \"\$val\" \"$@\""
208 [ -d /etc
/modules.d
] && {
210 sed 's/^[^#]/insmod &/' $
* | ash
2>&- ||
:
217 for file in $
(ls $1/*.sh
2>/dev
/null
); do
223 local PART
="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
224 local PREFIX
=/dev
/mtdblock
227 [ -d /dev
/mtdblock
] && PREFIX
=/dev
/mtdblock
/
228 echo "${PART:+$PREFIX$PART}"
231 strtok
() { # <string> { <variable> [<separator>] ... }
238 while [ $# -gt 1 ]; do
241 [ "$tmp" = "$val" ] && break
245 export ${NO_EXPORT:+-n} "$1=$tmp"; count
=$
((count
+1))
249 if [ $# -gt 0 -a -n "$val" ]; then
250 export ${NO_EXPORT:+-n} "$1=$val"; count
=$
((count
+1))
258 local part
="$(find_mtd_part "$1")"
260 echo Partition not found.
263 echo -e "\xde\xad\xc0\xde" | mtd
-qq write - "$1"
266 uci_apply_defaults
() {
267 cd /etc
/uci-defaults ||
return 0
269 [ -z "$files" ] && return 0
271 for file in $files; do
272 ( .
"./$(basename $file)" ) && rm -f "$file"
277 [ -z "$IPKG_INSTROOT" -a -f /lib
/config
/uci.sh
] && .
/lib
/config
/uci.sh
This page took 0.069066 seconds and 5 git commands to generate.