[source] base-files: split out preinit interface config
LEDE Commits
lede-commits at lists.infradead.org
Sat Aug 13 06:52:15 PDT 2016
jogo pushed a commit to source.git, branch master:
https://git.lede-project.org/?p=source.git;a=commitdiff;h=0f1ae840c9c4a556e24709d5573ca7bdb8fc75ec
commit 0f1ae840c9c4a556e24709d5573ca7bdb8fc75ec
Author: Jonas Gorski <jonas.gorski at gmail.com>
AuthorDate: Fri Aug 12 16:47:25 2016 +0200
base-files: split out preinit interface config
Move preinit interface and ip config to its own function to allow
calling it from more than one place.
Signed-off-by: Jonas Gorski <jonas.gorski at gmail.com>
---
package/base-files/files/lib/preinit/10_indicate_preinit | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit
index 717d35c..b9368d9 100644
--- a/package/base-files/files/lib/preinit/10_indicate_preinit
+++ b/package/base-files/files/lib/preinit/10_indicate_preinit
@@ -2,6 +2,13 @@
# Copyright (C) 2006 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
+preinit_ip_config() {
+ grep -q "$1" /proc/net/dev || return
+
+ ip link set dev $1 up
+ ip -4 address add $pi_ip/$pi_netmask broadcast $pi_broadcast dev $1
+}
+
preinit_ip() {
# if the preinit interface isn't specified and ifname is set in
# preinit.arch use that interface
@@ -9,10 +16,9 @@ preinit_ip() {
pi_ifname=$ifname
fi
- [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
- ip link set dev $pi_ifname up
- ip -4 address add $pi_ip/$pi_netmask broadcast $pi_broadcast dev $pi_ifname
- }
+ if [ -n "$pi_ifname" ]; then
+ preinit_ip_config $pi_ifname
+ fi
}
preinit_ip_deconfig() {
More information about the lede-commits
mailing list