]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/swconfig
Use bash as shebang in network initscripts
[ipfire-2.x.git] / src / initscripts / system / swconfig
1 #!/bin/sh
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 . /etc/sysconfig/rc
23 . ${rc_functions}
24
25 if [ -e /etc/init.d/swconfig.user ]; then
26 /etc/init.d/swconfig.user $*
27 exit ${?}
28 fi
29
30 if [ -e /var/ipfire/ethernet/swconfig_mac ]; then
31 SWMAC=`cat /var/ipfire/ethernet/swconfig_mac`
32 else
33 # Generate a random local administrated mac address for vlan swconfig.
34 SWMAC=`printf "%1x2:%02x:%02x:%02x:%02x" $[RANDOM%16] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256]`
35 echo $SWMAC > /var/ipfire/ethernet/swconfig_mac
36 fi
37
38 case "${1}" in
39 start)
40 case `cat /proc/device-tree/model 2>/dev/null` in
41 "Lamobo R1")
42 #
43 # Lamobo R1 aka BPi R1 Routerboard
44 #
45 # Speaker | LAN4 | LAN3 | LAN2 | LAN1 || WAN | HDMI
46 # SW-Port | P2 | P1 | P0 | P4 || P3 |
47 # MAC-Add | 14 | 13 | 12 | 11 || 10 |
48 #
49 # Switch-Port P8 - internal CPU Port
50
51 # stop udev...
52 killall udevd
53
54 device=`ls /sys/class/net/*/device/driver/1c50000.ethernet/net | head -1`
55 ip link set $device up
56
57 # set local mac addresses.
58 ip link set dev wan address $SWMAC:10
59 ip link set dev lan1 address $SWMAC:11
60 ip link set dev lan2 address $SWMAC:12
61 ip link set dev lan3 address $SWMAC:13
62 ip link set dev lan4 address $SWMAC:14
63
64 # start udev...
65 killall udevd
66 /etc/init.d/udev start
67 ;;
68 esac 2> /dev/null
69 exit 0
70 ;;
71
72 *)
73 echo "Usage: ${0} {start}"
74 exit 1
75 ;;
76 esac