base-files: do not write to /etc/config/wireless at boot time unless a new interface...
[librecmc/librecmc.git] / package / base-files / files / etc / init.d / network
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006-2011 OpenWrt.org
3
4 START=40
5 STOP=90
6
7 boot() {
8         setup_switch() { return 0; }
9
10         include /lib/network
11         setup_switch
12
13         /sbin/wifi detect > /tmp/wireless.tmp
14         [ -s /tmp/wireless.tmp ] && {
15                 cat /tmp/wireless.tmp >> /etc/config/wireless
16         }
17         rm -f /tmp/wireless.tmp
18         grep -qs config /etc/config/wireless && {
19                 /sbin/wifi up
20         }
21
22         scan_interfaces
23
24         local ifc
25         for ifc in $interfaces; do
26                 local proto
27                 config_get proto "$ifc" proto
28
29                 local auto
30                 config_get_bool auto "$ifc" auto 1
31
32                 type "coldplug_interface_$proto" >/dev/null && [ "$auto" = 1 ] && \
33                         coldplug_interface_$proto "$ifc"
34         done
35 }
36
37 start() {
38         setup_switch() { return 0; }
39         
40         include /lib/network
41         setup_switch
42         ifup -a
43         /sbin/wifi up
44 }
45
46 stop() {
47         ifdown -a
48 }
49
50 restart() {
51         start
52 }