2005-11-19 05:17:20 +02:00
|
|
|
#!/bin/sh
|
2005-02-06 02:52:16 +02:00
|
|
|
alias debug=${DEBUG:-:}
|
|
|
|
|
2006-06-20 00:45:07 +03:00
|
|
|
# newline
|
|
|
|
N="
|
|
|
|
"
|
|
|
|
|
2005-02-06 02:52:16 +02:00
|
|
|
# valid interface?
|
2005-05-30 12:09:58 +03:00
|
|
|
if_valid () (
|
2005-02-06 02:52:16 +02:00
|
|
|
ifconfig "$1" >&- 2>&- ||
|
|
|
|
[ "${1%%[0-9]}" = "br" ] ||
|
2005-05-30 12:09:58 +03:00
|
|
|
{ debug "# missing interface '$1' ignored"; false; }
|
|
|
|
)
|
|
|
|
|
2005-11-19 05:17:20 +02:00
|
|
|
hotplug_dev() {
|
|
|
|
env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug net
|
2005-10-22 23:47:19 +03:00
|
|
|
}
|
2006-05-10 21:17:12 +03:00
|
|
|
|
2006-06-20 00:45:07 +03:00
|
|
|
append() {
|
|
|
|
local var="$1"
|
|
|
|
local value="$2"
|
|
|
|
local sep="${3:- }"
|
|
|
|
eval "export ${var}=\"\${${var}:+\${${var}}${value:+$sep}}$value\""
|
|
|
|
}
|
|
|
|
|
2006-05-10 21:17:12 +03:00
|
|
|
config_cb() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
option_cb() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
config () {
|
|
|
|
config_cb "$@"
|
|
|
|
_C=$((${_C:-0} + 1))
|
|
|
|
export CONFIG_SECTION="${2:-cfg${_C}}"
|
|
|
|
export CONFIG_${CONFIG_SECTION}_TYPE="$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
option () {
|
|
|
|
local varname="$1" ; shift
|
|
|
|
export CONFIG_${CONFIG_SECTION}_${varname}="$*"
|
|
|
|
option_cb "$varname" "$*"
|
|
|
|
}
|
|
|
|
|
|
|
|
config_clear() {
|
|
|
|
[ -z "$CONFIG_SECTION" ] && return
|
|
|
|
for oldsetting in `set | grep ^CONFIG_${CONFIG_SECTION}_ | \
|
|
|
|
sed -e 's/\(.*\)=.*$/\1/'` ; do
|
|
|
|
unset $oldsetting
|
|
|
|
done
|
|
|
|
unset CONFIG_SECTION
|
|
|
|
}
|
|
|
|
|
|
|
|
config_load() {
|
|
|
|
local CD=""
|
|
|
|
if [ \! -e "$1" -a -e "/etc/config/$1" ]; then
|
|
|
|
cd /etc/config && local CD=1
|
|
|
|
fi
|
|
|
|
[ -e "$1" ] && . $1
|
|
|
|
${CD:+cd - >/dev/null}
|
|
|
|
${CONFIG_SECTION:+config_cb}
|
|
|
|
}
|
|
|
|
|
|
|
|
config_get() {
|
|
|
|
case "$3" in
|
|
|
|
"") eval "echo \${CONFIG_${1}_${2}}";;
|
|
|
|
*) eval "$1=\"\${CONFIG_${2}_${3}}\"";;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
config_set() {
|
|
|
|
export CONFIG_${1}_${2}="${3}"
|
|
|
|
}
|
2006-05-30 22:38:38 +03:00
|
|
|
|
|
|
|
load_modules() {
|
|
|
|
sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
|
|
|
|
}
|