mirror of
https://github.com/openwrt/openwrt.git
synced 2026-10-12 06:57:57 +04:00
base-files: configure the preinit interface on hotplug
preinit_ip runs once when preinit starts and configures the preinit interface only if its driver has already registered it. Drivers that probe while preinit is running leave failsafe without a network. Run procd's preinit hotplug daemon on net add events, as the rule in hotplug-preinit.json.d does, and have it start /sbin/preinit-netdev. The script runs the new preinit_netdev boot hook, which targets use to rename the new netdev, and then calls preinit_ip_event, which configures the preinit interface unless it already carries the preinit address. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
1 parent
60043441a0
commit
ac0b20dbce
4 files changed
+44
No files matched your search
@@ -194,6 +194,7 @@ define Package/base-files/install
|
||||
|
||||
$(SED) "s#%PATH%#$(TARGET_INIT_PATH)#g" \
|
||||
$(1)/sbin/hotplug-call \
|
||||
$(1)/sbin/preinit-netdev \
|
||||
$(1)/etc/preinit \
|
||||
$(1)/etc/profile
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[
|
||||
[ "if",
|
||||
[ "and",
|
||||
[ "eq", "ACTION", "add" ],
|
||||
[ "eq", "SUBSYSTEM", "net" ]
|
||||
],
|
||||
[
|
||||
[ "exec", "/sbin/preinit-netdev" ]
|
||||
]
|
||||
]
|
||||
]
|
||||
@@ -184,6 +184,23 @@ preinit_ip() {
|
||||
preinit_net_echo "Doing OpenWrt Preinit\n"
|
||||
}
|
||||
|
||||
preinit_ip_event() {
|
||||
[ "$pi_preinit_no_failsafe" = "y" ] && return
|
||||
|
||||
if [ -z "$pi_ifname" ]; then
|
||||
type set_preinit_iface > /dev/null 2>&1 && set_preinit_iface
|
||||
pi_ifname=$ifname
|
||||
fi
|
||||
|
||||
[ -n "$pi_ifname" ] || return
|
||||
|
||||
ip -4 -o address show dev "$pi_ifname" 2> /dev/null | \
|
||||
grep -q "inet $pi_ip/" && return
|
||||
|
||||
preinit_ip_config "$pi_ifname"
|
||||
preinit_net_echo "Doing OpenWrt Preinit\n"
|
||||
}
|
||||
|
||||
preinit_ip_deconfig() {
|
||||
[ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
|
||||
local netdev vid
|
||||
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2026 OpenWrt.org
|
||||
|
||||
export PATH="%PATH%"
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/preinit.sh
|
||||
. /lib/functions/system.sh
|
||||
|
||||
for pi_source_file in /lib/preinit/*; do
|
||||
. $pi_source_file
|
||||
done
|
||||
|
||||
boot_run_hook preinit_netdev
|
||||
preinit_ip_event
|
||||
Reference in new issue
Block a user