mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-24 11:16:51 +00:00
initramfs: enable DNS if network is up
In certain situations, it is desirable for hostnames to be resolvable in the initramfs (e.g., when a hostname is specified as the NFS server in the "boot" or "disk" kernel parameters). If the network is up when the init script is executed (e.g., when the "ip" kernel parameter is specified) and a DNS server is known, write it to /etc/resolv.conf so it can be used for DNS requests.
This commit is contained in:
parent
dce9240b0d
commit
635d8b2988
3
packages/devel/glibc/config/nsswitch-init.conf
Normal file
3
packages/devel/glibc/config/nsswitch-init.conf
Normal file
@ -0,0 +1,3 @@
|
||||
# This is just enough to get DNS resolution working in the initramfs
|
||||
|
||||
hosts: dns
|
@ -151,7 +151,7 @@ post_makeinstall_target() {
|
||||
|
||||
# create default configs
|
||||
mkdir -p $INSTALL/etc
|
||||
cp $PKG_DIR/config/nsswitch.conf $INSTALL/etc
|
||||
cp $PKG_DIR/config/nsswitch-target.conf $INSTALL/etc/nsswitch.conf
|
||||
cp $PKG_DIR/config/host.conf $INSTALL/etc
|
||||
cp $PKG_DIR/config/gai.conf $INSTALL/etc
|
||||
|
||||
@ -176,8 +176,16 @@ makeinstall_init() {
|
||||
cp -PR $PKG_BUILD/.$TARGET_NAME/math/libm.so* $INSTALL/usr/lib
|
||||
cp -PR $PKG_BUILD/.$TARGET_NAME/nptl/libpthread.so* $INSTALL/usr/lib
|
||||
cp -PR $PKG_BUILD/.$TARGET_NAME/rt/librt.so* $INSTALL/usr/lib
|
||||
cp -PR $PKG_BUILD/.$TARGET_NAME/resolv/libnss_dns.so* $INSTALL/usr/lib
|
||||
cp -PR $PKG_BUILD/.$TARGET_NAME/resolv/libresolv.so* $INSTALL/usr/lib
|
||||
|
||||
if [ "$TARGET_ARCH" = "arm" -a "$TARGET_FLOAT" = "hard" ]; then
|
||||
ln -sf ld.so $INSTALL/usr/lib/ld-linux.so.3
|
||||
fi
|
||||
}
|
||||
|
||||
post_makeinstall_init() {
|
||||
# create default configs
|
||||
mkdir -p $INSTALL/etc
|
||||
cp $PKG_DIR/config/nsswitch-init.conf $INSTALL/etc/nsswitch.conf
|
||||
}
|
||||
|
@ -1003,6 +1003,10 @@
|
||||
[ -f "/sysroot/usr/lib/systemd/systemd" ] || error "final_check" "Could not find systemd!"
|
||||
}
|
||||
|
||||
# If the network is up (due to the use of the "ip" kernel parameter) and a DNS
|
||||
# server is known, allow the libc resolver to use it
|
||||
grep '^\(nameserver\|domain\) ' /proc/net/pnp | grep -v '^nameserver 0\.0\.0\.0$' > /etc/resolv.conf
|
||||
|
||||
if [ "${boot%%=*}" = "FILE" ]; then
|
||||
error "check arguments" "boot argument can't be FILE type..."
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user