From: Michael Tremer Date: Mon, 9 Mar 2015 14:35:57 +0000 (+0100) Subject: network: Configure device names from /var/ipfire/ethernet/settings X-Git-Tag: v2.17-core91~163^2~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=600b99fb315f02cd778b7725cdf54ca95caf095d;p=people%2Fstevee%2Fipfire-2.x.git network: Configure device names from /var/ipfire/ethernet/settings Instead of creating a copy of the configuration values and for better extensibility, we will have udev execute a script that parses /var/ipfire/ethernet/settings and will return the correct name of the corresponding device (green0, blue0, ...). --- diff --git a/config/rootfiles/common/armv5tel/initscripts b/config/rootfiles/common/armv5tel/initscripts index 53bc64f9a8..05b8ceebe8 100755 --- a/config/rootfiles/common/armv5tel/initscripts +++ b/config/rootfiles/common/armv5tel/initscripts @@ -60,6 +60,7 @@ etc/rc.d/init.d/mounttmpfs #etc/rc.d/init.d/mysql #etc/rc.d/init.d/netsnmpd etc/rc.d/init.d/network +etc/rc.d/init.d/network-trigger etc/rc.d/init.d/network-vlans #etc/rc.d/init.d/networking etc/rc.d/init.d/networking/any @@ -228,6 +229,7 @@ etc/rc.d/rcsysinit.d/S73swconfig etc/rc.d/rcsysinit.d/S75firstsetup etc/rc.d/rcsysinit.d/S80localnet etc/rc.d/rcsysinit.d/S85firewall +etc/rc.d/rcsysinit.d/S90network-trigger etc/rc.d/rcsysinit.d/S91network-vlans etc/rc.d/rcsysinit.d/S92rngd etc/rc.d/rc3.d/S15fireinfo diff --git a/config/rootfiles/common/i586/initscripts b/config/rootfiles/common/i586/initscripts index 7bab7c4f94..d4779ab054 100755 --- a/config/rootfiles/common/i586/initscripts +++ b/config/rootfiles/common/i586/initscripts @@ -62,6 +62,7 @@ etc/rc.d/init.d/mounttmpfs #etc/rc.d/init.d/mysql #etc/rc.d/init.d/netsnmpd etc/rc.d/init.d/network +etc/rc.d/init.d/network-trigger etc/rc.d/init.d/network-vlans #etc/rc.d/init.d/networking etc/rc.d/init.d/networking/any @@ -233,6 +234,7 @@ etc/rc.d/rcsysinit.d/S70console etc/rc.d/rcsysinit.d/S75firstsetup etc/rc.d/rcsysinit.d/S80localnet etc/rc.d/rcsysinit.d/S85firewall +etc/rc.d/rcsysinit.d/S90network-trigger etc/rc.d/rcsysinit.d/S91network-vlans etc/rc.d/rcsysinit.d/S92rngd etc/rc.d/rc3.d/S15fireinfo diff --git a/config/rootfiles/common/udev b/config/rootfiles/common/udev index bc1cdaa1ff..d01c461015 100644 --- a/config/rootfiles/common/udev +++ b/config/rootfiles/common/udev @@ -2,7 +2,6 @@ bin/udevadm etc/modprobe.d/blacklist.conf etc/udev #etc/udev/rules.d -#etc/udev/rules.d/30-persistent-network.rules #etc/udev/rules.d/55-lfs.rules #etc/udev/rules.d/81-cdrom.rules #etc/udev/rules.d/83-cdrom-symlinks.rules @@ -29,6 +28,7 @@ lib/udev #lib/udev/hwdb.d/60-keyboard.hwdb #lib/udev/init-net-rules.sh #lib/udev/mtd_probe +#lib/udev/network-hotplug-rename #lib/udev/rule_generator.functions #lib/udev/rules.d #lib/udev/rules.d/25-alsa.rules @@ -37,6 +37,7 @@ lib/udev #lib/udev/rules.d/50-udev-default.rules #lib/udev/rules.d/60-cdrom_id.rules #lib/udev/rules.d/60-keyboard.rules +#lib/udev/rules.d/60-net.rules #lib/udev/rules.d/60-persistent-alsa.rules #lib/udev/rules.d/60-persistent-input.rules #lib/udev/rules.d/60-persistent-serial.rules diff --git a/config/udev/60-net.rules b/config/udev/60-net.rules new file mode 100644 index 0000000000..4f22a1e306 --- /dev/null +++ b/config/udev/60-net.rules @@ -0,0 +1,3 @@ +# Call a script that checks for the right name of the new device. +# If it matches the configuration it will be renamed accordingly. +ACTION=="add", SUBSYSTEM=="net", PROGRAM="/lib/udev/network-hotplug-rename", RESULT=="?*", NAME="$result" diff --git a/config/udev/network-hotplug-rename b/config/udev/network-hotplug-rename new file mode 100644 index 0000000000..331b788185 --- /dev/null +++ b/config/udev/network-hotplug-rename @@ -0,0 +1,75 @@ +#!/bin/bash +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2015 IPFire Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +# Check if all appropriate variables are set +[ -n "${INTERFACE}" ] || exit 2 + +# Ignore virtual interfaces, etc. +case "${INTERFACE}" in + lo) + exit 0 + ;; + tun*) + exit 0 + ;; + ppp*) + exit 0 + ;; +esac + +# Check if INTERFACE actually exists +[ -d "/sys/class/net/${INTERFACE}" ] || exit 1 + +# If the network configuration is not readable, +# we cannot go on. +if [ ! -r "/var/ipfire/ethernet/settings" ]; then + exit 1 +fi + +# Read network settings +eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) + +# Standard zones +ZONES="RED GREEN ORANGE BLUE" + +# Determine the address of INTERFACE +ADDRESS="$(