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 [ "$OLD" -a "$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
88 local file="$UCI_ROOT/etc
/config
/$1"
90 export ${NO_EXPORT:+-n} CONFIG_SECTIONS=
91 export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=0
92 export ${NO_EXPORT:+-n} CONFIG_SECTION=
98 ${CONFIG_SECTION:+config_cb}
103 "") eval "echo \"\
${CONFIG_${1}_${2}}\"";;
104 *) eval "export ${NO_EXPORT:+-n} -- \"$1=\${CONFIG_${2}_${3}}\"";;
108 # config_get_bool <variable> <section> <option> [<default>]
111 config_get "_tmp
" "$2" "$3"
113 1|on|enabled) export ${NO_EXPORT:+-n} "$1=1";;
114 0|off|disabled) export ${NO_EXPORT:+-n} "$1=0";;
115 *) eval "$1=${4:-0}";;
123 local old_section="$CONFIG_SECTION"
125 CONFIG_SECTION="$section"
126 option "$option" "$value"
127 CONFIG_SECTION="$old_section"
133 local section cfgtype
135 [ -z "$CONFIG_SECTIONS" ] && return 0
136 for section in ${CONFIG_SECTIONS}; do
137 config_get cfgtype "$section" TYPE
138 [ -n "$type" -a "$cfgtype" != "$type" ] && continue
139 eval "$function \"\
$section\""
144 [ -d /etc/modules.d ] && {
146 sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
153 for file in $(ls $1/*.sh 2>/dev/null); do
159 local PART="$
(grep "\"$1\"" /proc
/mtd |
awk -F: '{print $1}')"
160 local PREFIX=/dev/mtdblock
163 [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
164 echo "${PART:+$PREFIX$PART}"
167 strtok() { # <string> { <variable> [<separator>] ... }
174 while [ $# -gt 1 ]; do
177 [ "$tmp" = "$val" ] && break
181 export ${NO_EXPORT:+-n} "$1=$tmp"; count=$((count+1))
185 if [ $# -gt 0 -a "$val" ]; then
186 export ${NO_EXPORT:+-n} "$1=$val"; count=$((count+1))
194 local part="$
(find_mtd_part
"$1")"
196 echo Partition not found.
199 echo -e "\xde\xad\xc0\xde" | mtd -qq write - "$1"
This page took 0.060994 seconds and 5 git commands to generate.