]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/initscripts/system/swconfig
Merge branch 'next'
[people/pmueller/ipfire-2.x.git] / src / initscripts / system / swconfig
CommitLineData
ffeb717f
AF
1#!/bin/sh
2########################################################################
3# Begin $rc_base/init.d/swconfig
4#
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########################################################################
9
10. /etc/sysconfig/rc
11. ${rc_functions}
12
13if [ -e /etc/init.d/swconfig.user ]; then
14 /etc/init.d/swconfig.user $*
15 exit ${?}
16fi
17
18if [ -e /var/ipfire/ethernet/swconfig_mac ]; then
19SWMAC=`cat /var/ipfire/ethernet/swconfig_mac`
20else
21# Generate a random local administrated mac address for vlan swconfig.
22SWMAC=`printf "%1x2:%02x:%02x:%02x:%02x" $[RANDOM%16] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256]`
23echo $SWMAC > /var/ipfire/ethernet/swconfig_mac
24fi
25
26case "${1}" in
27 start)
309b7de8 28 case `cat /proc/device-tree/model 2>/dev/null` in
ffeb717f
AF
29 "Lamobo-R1")
30 #
31 # Lamobo R1 aka BPi R1 Routerboard
32 #
33 # Speaker | LAN1 | LAN2 | LAN3 | LAN4 || LAN5 | HDMI
34 # SW-Port | P2 | P1 | P0 | P4 || P3 |
35 # VLAN | 11 | 12 | 13 | 14 ||ALL(t)|
36 #
37 # Switch-Port P8 - ALL(t) boards internal CPU Port
38 #
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
46 # configure vlans
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"
51 # activate new config
52 swconfig dev $device set apply 1
53 # create interfaces for the vlan's
54 modprobe 8021q
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...
65 killall udevd
66 /etc/init.d/udev start
67 ;;
68 esac
69 exit 0
70 ;;
71
72 *)
73 echo "Usage: ${0} {start}"
74 exit 1
75 ;;
76esac
77
78# End $rc_base/init.d/swconfig
79