diff options
author | Jonas Gorski <jonas.gorski@gmail.com> | 2016-08-12 16:47:25 +0200 |
---|---|---|
committer | Jonas Gorski <jonas.gorski@gmail.com> | 2016-08-13 15:49:56 +0200 |
commit | 0f1ae840c9c4a556e24709d5573ca7bdb8fc75ec (patch) | |
tree | f3487bc198a62de0f8c20732c0c22821904b6433 | |
parent | 780ccbf9f1ca60ecb6f125fb6d6d3a0652446685 (diff) | |
download | upstream-0f1ae840c9c4a556e24709d5573ca7bdb8fc75ec.tar.gz upstream-0f1ae840c9c4a556e24709d5573ca7bdb8fc75ec.tar.bz2 upstream-0f1ae840c9c4a556e24709d5573ca7bdb8fc75ec.zip |
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@gmail.com>
-rw-r--r-- | package/base-files/files/lib/preinit/10_indicate_preinit | 14 |
1 files 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 717d35cc30..b9368d90a9 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() { |