2 # Copyright (C) 2006 OpenWrt.org
3 # Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
5 alias debug
=${DEBUG:-:}
15 env
-i ACTION
=$1 INTERFACE
=$2 /sbin
/hotplug-call net
23 eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\""
27 config_cb
() { return 0; }
28 option_cb
() { return 0; }
36 export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS
=$
(($CONFIG_NUM_SECTIONS + 1))
37 name
="${name:-cfg$CONFIG_NUM_SECTIONS}"
38 append CONFIG_SECTIONS
"$name"
39 [ -n "$NO_CALLBACK" ] || config_cb
"$cfgtype" "$name"
40 export ${NO_EXPORT:+-n} CONFIG_SECTION
="$name"
41 export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_TYPE=$cfgtype"
45 local varname
="$1"; shift
48 export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_${varname}=$value"
49 [ -n "$NO_CALLBACK" ] || option_cb "$varname" "$
*"
58 [ -n "$OLD" -a -n "$NEW" ] || return
59 for oldvar in `set | grep ^CONFIG_${OLD}_ | \
60 sed -e 's/\(.*\)=.*$/\1/'` ; do
61 newvar="CONFIG_
${NEW}_${oldvar##CONFIG_${OLD}_}"
62 eval "export ${NO_EXPORT:+-n} \"$newvar=\
${$oldvar}\""
65 export ${NO_EXPORT:+-n} CONFIG_SECTIONS="$
(echo " $CONFIG_SECTIONS " |
sed -e "s, $OLD , $NEW ,")"
67 [ "$CONFIG_SECTION" = "$OLD" ] && export ${NO_EXPORT:+-n} CONFIG_SECTION="$NEW"
71 config_set "$1" "$2" ""
78 export ${NO_EXPORT:+-n} CONFIG_SECTIONS="$
(echo " $CONFIG_SECTIONS " |
sed -e "s, $OLD , ,")"
79 export ${NO_EXPORT:+-n} CONFIG_SECTIONS="${SECTION:+$CONFIG_SECTIONS}"
81 for oldvar in `set | grep ^CONFIG_${SECTION:+${SECTION}_} | \
82 sed -e 's/\(.*\)=.*$/\1/'` ; do
96 *) cfg="$UCI_ROOT/etc
/config
/$PACKAGE"
97 uci="/tmp
/.uci
/${PACKAGE}"
101 [ -e "$cfg" ] || cfg=""
102 [ -e "$uci" ] || uci=""
105 [ -z "$cfg" -a -z "$uci" ] && return 1
108 export ${NO_EXPORT:+-n} CONFIG_SECTIONS=
109 export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=0
110 export ${NO_EXPORT:+-n} CONFIG_SECTION=
115 ${CONFIG_SECTION:+config_cb}
120 "") eval "echo \"\
${CONFIG_${1}_${2}}\"";;
121 *) eval "export ${NO_EXPORT:+-n} -- \"$1=\${CONFIG_${2}_${3}}\"";;
125 # config_get_bool <variable> <section> <option> [<default>]
128 config_get "_tmp
" "$2" "$3"
130 1|on|enabled) export ${NO_EXPORT:+-n} "$1=1";;
131 0|off|disabled) export ${NO_EXPORT:+-n} "$1=0";;
132 *) eval "$1=${4:-0}";;
140 local old_section="$CONFIG_SECTION"
142 CONFIG_SECTION="$section"
143 option "$option" "$value"
144 CONFIG_SECTION="$old_section"
149 [ "$#" -ge 1 ] && shift
151 [ "$#" -ge 1 ] && shift
152 local section cfgtype
154 [ -z "$CONFIG_SECTIONS" ] && return 0
155 for section in ${CONFIG_SECTIONS}; do
156 config_get cfgtype "$section" TYPE
157 [ -n "$type" -a "x
$cfgtype" != "x
$type" ] && continue
158 eval "$function \"\
$section\" \"\$@
\""
163 [ -d /etc/modules.d ] && {
165 sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
172 for file in $(ls $1/*.sh 2>/dev/null); do
178 local PART="$
(grep "\"$1\"" /proc
/mtd |
awk -F: '{print $1}')"
179 local PREFIX=/dev/mtdblock
182 [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
183 echo "${PART:+$PREFIX$PART}"
186 strtok() { # <string> { <variable> [<separator>] ... }
193 while [ $# -gt 1 ]; do
196 [ "$tmp" = "$val" ] && break
200 export ${NO_EXPORT:+-n} "$1=$tmp"; count=$((count+1))
204 if [ $# -gt 0 -a -n "$val" ]; then
205 export ${NO_EXPORT:+-n} "$1=$val"; count=$((count+1))
213 local part="$
(find_mtd_part
"$1")"
215 echo Partition not found.
218 echo -e "\xde\xad\xc0\xde" | mtd -qq write - "$1"
This page took 0.058745 seconds and 5 git commands to generate.