2 # Copyright (C) 2006 OpenWrt.org
3 # Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
5 alias debug
=${DEBUG:-:}
16 env
-i ACTION
=$1 INTERFACE
=$2 /sbin
/hotplug-call net
24 eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\""
28 [ -n "$IPKG_INSTROOT" ] && return 0
33 config_cb
() { return 0; }
34 option_cb
() { return 0; }
46 export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS
=$
(($CONFIG_NUM_SECTIONS + 1))
47 name
="${name:-cfg$CONFIG_NUM_SECTIONS}"
48 append CONFIG_SECTIONS
"$name"
49 [ -n "$NO_CALLBACK" ] || config_cb
"$cfgtype" "$name"
50 export ${NO_EXPORT:+-n} CONFIG_SECTION
="$name"
51 export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_TYPE=$cfgtype"
55 local varname
="$1"; shift
58 export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_${varname}=$value"
59 [ -n "$NO_CALLBACK" ] || option_cb "$varname" "$
*"
68 [ -n "$OLD" -a -n "$NEW" ] || return
69 for oldvar in `set | grep ^CONFIG_${OLD}_ | \
70 sed -e 's/\(.*\)=.*$/\1/'` ; do
71 newvar="CONFIG_
${NEW}_${oldvar##CONFIG_${OLD}_}"
72 eval "export ${NO_EXPORT:+-n} \"$newvar=\
${$oldvar}\""
75 export ${NO_EXPORT:+-n} CONFIG_SECTIONS="$
(echo " $CONFIG_SECTIONS " |
sed -e "s, $OLD , $NEW ,")"
77 [ "$CONFIG_SECTION" = "$OLD" ] && export ${NO_EXPORT:+-n} CONFIG_SECTION="$NEW"
81 config_set "$1" "$2" ""
88 export ${NO_EXPORT:+-n} CONFIG_SECTIONS="$
(echo " $CONFIG_SECTIONS " |
sed -e "s, $OLD , ,")"
89 export ${NO_EXPORT:+-n} CONFIG_SECTIONS="${SECTION:+$CONFIG_SECTIONS}"
91 for oldvar in `set | grep ^CONFIG_${SECTION:+${SECTION}_} | \
92 sed -e 's/\(.*\)=.*$/\1/'` ; do
99 "") eval "echo \"\
${CONFIG_${1}_${2}}\"";;
100 *) eval "export ${NO_EXPORT:+-n} -- \"$1=\${CONFIG_${2}_${3}}\"";;
104 # config_get_bool <variable> <section> <option> [<default>]
107 config_get "_tmp
" "$2" "$3"
109 1|on|true|enabled) export ${NO_EXPORT:+-n} "$1=1";;
110 0|off|false|disabled) export ${NO_EXPORT:+-n} "$1=0";;
119 local old_section="$CONFIG_SECTION"
121 CONFIG_SECTION="$section"
122 option "$option" "$value"
123 CONFIG_SECTION="$old_section"
128 [ "$#" -ge 1 ] && shift
130 [ "$#" -ge 1 ] && shift
131 local section cfgtype
133 [ -z "$CONFIG_SECTIONS" ] && return 0
134 for section in ${CONFIG_SECTIONS}; do
135 config_get cfgtype "$section" TYPE
136 [ -n "$type" -a "x
$cfgtype" != "x
$type" ] && continue
137 eval "$function \"\
$section\" \"\$@
\""
142 [ -d /etc/modules.d ] && {
144 sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
151 for file in $(ls $1/*.sh 2>/dev/null); do
157 local PART="$
(grep "\"$1\"" /proc
/mtd |
awk -F: '{print $1}')"
158 local PREFIX=/dev/mtdblock
161 [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
162 echo "${PART:+$PREFIX$PART}"
165 strtok() { # <string> { <variable> [<separator>] ... }
172 while [ $# -gt 1 ]; do
175 [ "$tmp" = "$val" ] && break
179 export ${NO_EXPORT:+-n} "$1=$tmp"; count=$((count+1))
183 if [ $# -gt 0 -a -n "$val" ]; then
184 export ${NO_EXPORT:+-n} "$1=$val"; count=$((count+1))
192 local part="$
(find_mtd_part
"$1")"
194 echo Partition not found.
197 echo -e "\xde\xad\xc0\xde" | mtd -qq write - "$1"
200 uci_apply_defaults() {(
201 cd /etc/uci-defaults || return 0
203 [ -z "$files" ] && return 0
205 for file in $files; do
206 ( . ".
/$
(basename $file)" ) && rm -f "$file"
211 [ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh
This page took 0.058007 seconds and 5 git commands to generate.