source: bootscripts-embedded/clfs/rc.d/init.d/bcm47xx-switch @ 73ee2a6

Last change on this file since 73ee2a6 was 73ee2a6, checked in by Andrew Bradford <bradfa@…>, 12 years ago

Imported new bootscripts

Imported bootscripts that did not yet exist from clfs-embedded/bootscripts
as bootscripts should be kept in this repo rather than in the
clfs-embedded repo.

These scripts have NOT BEEN TESTED! (yet)
This is part of a cleanup of bootscripts.

  • Property mode set to 100755
File size: 1.6 KB
Line 
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
9if [ ! -x /sbin/robocfg ]; then
10        echo -n "Setting up vlan: /sbin/robocfg not found "
11        false
12        check_status
13fi
14
15if [ ! -x /sbin/vconfig ]; then
16        echo -n "Setting up vlan: /sbin/vconfig not found "
17        false
18        check_status
19fi
20
21if [ ! -x /sbin/nvram ]; then
22        echo -n "Setting up vlan: /sbin/nvram not found "
23        false
24        check_status
25fi
26
27case "$1" in
28start)
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        ;;
59stop)
60        # FIXME: Should we really do something at shutdown?
61        exit 0
62        ;;
63restart)
64        $0 stop
65        $0 start
66        ;;
67status)
68        robocfg show
69        ;;
70*)
71        echo "Usage: $0 {start|stop|restart|status}"
72        exit 1
73esac
74
Note: See TracBrowser for help on using the repository browser.