1 | #!/bin/ash
|
---|
2 | #
|
---|
3 | # Broadcom 47xx vlan and switch configuration init script
|
---|
4 | #
|
---|
5 | # Config: uses the 'nvram' settings for setting up vlan devices
|
---|
6 |
|
---|
7 | . /etc/rc.d/init.d/functions
|
---|
8 |
|
---|
9 | if [ ! -x /sbin/robocfg ]; then
|
---|
10 | echo -n "Setting up vlan: /sbin/robocfg not found "
|
---|
11 | false
|
---|
12 | check_status
|
---|
13 | fi
|
---|
14 |
|
---|
15 | if [ ! -x /sbin/vconfig ]; then
|
---|
16 | echo -n "Setting up vlan: /sbin/vconfig not found "
|
---|
17 | false
|
---|
18 | check_status
|
---|
19 | fi
|
---|
20 |
|
---|
21 | if [ ! -x /sbin/nvram ]; then
|
---|
22 | echo -n "Setting up vlan: /sbin/nvram not found "
|
---|
23 | false
|
---|
24 | check_status
|
---|
25 | fi
|
---|
26 |
|
---|
27 | case "$1" in
|
---|
28 | start)
|
---|
29 |
|
---|
30 | # Add a specific workaround for the case of weirdly set wireless mac address
|
---|
31 | # Do what openwrt is doing, and increment the last hex with 2
|
---|
32 | if [ "`nvram get il0macaddr`" = 00:90:4c:5f:00:2a ]; then
|
---|
33 | et0="$(nvram get et0macaddr)"
|
---|
34 | prefix="$(echo $et0 | sed -e 's/:..$//')"
|
---|
35 | addendum=$(( (0x$(echo $et0 | sed -e s/.*://g) + 2) % 256 ))
|
---|
36 | il0=$(printf %s:%02x $prefix $addendum)
|
---|
37 | echo -n "Fixing up wlan0 mac address: "
|
---|
38 | nvram set il0macaddr=$il0 && nvram commit
|
---|
39 | check_status
|
---|
40 | ifconfig wlan0 hw ether $il0 2>/dev/null
|
---|
41 | fi
|
---|
42 |
|
---|
43 | # eth0 has to be up for this
|
---|
44 | ifconfig eth0 up
|
---|
45 |
|
---|
46 | robocfg switch disable
|
---|
47 | robocfg vlans enable reset
|
---|
48 |
|
---|
49 | nvram show | grep vlan[0-4]ports= | sed -e s/vlan// -e s/ports=/\ / |
|
---|
50 | while read vlan ports; do
|
---|
51 | echo -n "Bringing up eth0.${vlan}: "
|
---|
52 | robocfg vlan ${vlan} ports "${ports}" &&
|
---|
53 | vconfig add eth0 $vlan
|
---|
54 | check_status
|
---|
55 | done
|
---|
56 | robocfg switch enable
|
---|
57 | exit 0
|
---|
58 | ;;
|
---|
59 | stop)
|
---|
60 | # FIXME: Should we really do something at shutdown?
|
---|
61 | exit 0
|
---|
62 | ;;
|
---|
63 | restart)
|
---|
64 | $0 stop
|
---|
65 | $0 start
|
---|
66 | ;;
|
---|
67 | status)
|
---|
68 | robocfg show
|
---|
69 | ;;
|
---|
70 | *)
|
---|
71 | echo "Usage: $0 {start|stop|restart|status}"
|
---|
72 | exit 1
|
---|
73 | esac
|
---|
74 |
|
---|