]>
git.ipfire.org Git - people/dweismueller/ipfire-2.x.git/blob - src/initscripts/init.d/swconfig
2 ########################################################################
3 # Begin $rc_base/init.d/swconfig
5 # Description : Script to setup lan switch.
6 # don't edit this script! If you want change the functions
7 # create an own script called swconfig.user
8 ########################################################################
13 if [ -e /etc
/init.d
/swconfig.user
]; then
14 /etc
/init.d
/swconfig.user $
*
18 if [ -e /var
/ipfire
/ethernet
/swconfig_mac
]; then
19 SWMAC
=`cat /var/ipfire/ethernet/swconfig_mac`
21 # Generate a random local administrated mac address for vlan swconfig.
22 SWMAC
=`printf "%1x2:%02x:%02x:%02x:%02x" $[RANDOM%16] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256]`
23 echo $SWMAC > /var
/ipfire
/ethernet
/swconfig_mac
28 case `cat /proc/device-tree/model` in
31 # Lamobo R1 aka BPi R1 Routerboard
33 # Speaker | LAN1 | LAN2 | LAN3 | LAN4 || LAN5 | HDMI
34 # SW-Port | P2 | P1 | P0 | P4 || P3 |
35 # VLAN | 11 | 12 | 13 | 14 ||ALL(t)|
37 # Switch-Port P8 - ALL(t) boards internal CPU Port
39 device
=`ls /sys/class/net/*/device/stmmac-0* | head -1 | cut -d/ -f5`
40 ip link
set $device up
41 boot_mesg
"Configure vlan-switch on $device ..."
42 # Reset switch, counter and enable vlan mode
43 swconfig dev
$device set reset 1
44 swconfig dev
$device set reset_mib
1
45 swconfig dev
$device set enable_vlan
1
47 swconfig dev
$device vlan
11 set ports
"2 3t 8t"
48 swconfig dev
$device vlan
12 set ports
"1 3t 8t"
49 swconfig dev
$device vlan
13 set ports
"0 3t 8t"
50 swconfig dev
$device vlan
14 set ports
"4 3t 8t"
52 swconfig dev
$device set apply
1
53 # create interfaces for the vlan's
55 vconfig add
$device 11
56 vconfig add
$device 12
57 vconfig add
$device 13
58 vconfig add
$device 14
59 # set local mac addresses.
60 ip link
set dev
$device.11 address
$SWMAC:11
61 ip link
set dev
$device.12 address
$SWMAC:12
62 ip link
set dev
$device.13 address
$SWMAC:13
63 ip link
set dev
$device.14 address
$SWMAC:14
64 # need to restart udev...
66 /etc
/init.d
/udev start
73 echo "Usage: ${0} {start}"
78 # End $rc_base/init.d/swconfig