move source file to src/ and let the kernel tree build the modules.
[openwrt.git] / package / base-files / default / etc / functions.sh
1 #!/bin/sh
2 alias debug=${DEBUG:-:}
3
4 # valid interface?
5 if_valid () (
6 ifconfig "$1" >&- 2>&- ||
7 [ "${1%%[0-9]}" = "br" ] ||
8 { debug "# missing interface '$1' ignored"; false; }
9 )
10
11 hotplug_dev() {
12 env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug net
13 }
14
15 config_cb() {
16 return 0
17 }
18 option_cb() {
19 return 0
20 }
21
22 config () {
23 config_cb "$@"
24 _C=$((${_C:-0} + 1))
25 export CONFIG_SECTION="${2:-cfg${_C}}"
26 export CONFIG_${CONFIG_SECTION}_TYPE="$1"
27 }
28
29 option () {
30 local varname="$1" ; shift
31 export CONFIG_${CONFIG_SECTION}_${varname}="$*"
32 option_cb "$varname" "$*"
33 }
34
35 config_clear() {
36 [ -z "$CONFIG_SECTION" ] && return
37 for oldsetting in `set | grep ^CONFIG_${CONFIG_SECTION}_ | \
38 sed -e 's/\(.*\)=.*$/\1/'` ; do
39 unset $oldsetting
40 done
41 unset CONFIG_SECTION
42 }
43
44 config_load() {
45 local CD=""
46 if [ \! -e "$1" -a -e "/etc/config/$1" ]; then
47 cd /etc/config && local CD=1
48 fi
49 [ -e "$1" ] && . $1
50 ${CD:+cd - >/dev/null}
51 ${CONFIG_SECTION:+config_cb}
52 }
53
54 config_get() {
55 case "$3" in
56 "") eval "echo \${CONFIG_${1}_${2}}";;
57 *) eval "$1=\"\${CONFIG_${2}_${3}}\"";;
58 esac
59 }
60
61 config_set() {
62 export CONFIG_${1}_${2}="${3}"
63 }
64
65 load_modules() {
66 sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
67 }
This page took 0.048695 seconds and 5 git commands to generate.