From 5d829265db1b9a6bef80dc0d0a0abee5aa2eac97 Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Fri, 14 Mar 2014 18:21:40 +0400 Subject: [PATCH] live, net: shift and rework network and resolver setup 50-setup-network was a hasty hack (surprise!) that used to do what net and net-eth features have been created to do since; just drop the duplicated crufty code. Unconditional resolver setup isn't done now: those with static setup are better off doing it explicitly, and those with DHCP should be fine already. NB: /etc/hosts *is* fine within setup package *but* hasher will overwrite it with a copy of host's one; let's reset contents to initial at least until hasher gets fixed and the fix is rather deployed in the wild. --- features.in/live/config.mk | 2 +- .../live/image-scripts.d/50-setup-network | 67 ------------------- .../net/rootfs/image-scripts.d/50-net-resolv | 17 +++++ 3 files changed, 18 insertions(+), 68 deletions(-) delete mode 100755 features.in/live/live/image-scripts.d/50-setup-network create mode 100755 features.in/net/rootfs/image-scripts.d/50-net-resolv diff --git a/features.in/live/config.mk b/features.in/live/config.mk index 28009d24..09ad5811 100644 --- a/features.in/live/config.mk +++ b/features.in/live/config.mk @@ -18,7 +18,7 @@ use/live: use/stage2 sub/rootfs@live sub/stage2@live use/services @$(call add,DEFAULT_SERVICES_ENABLE,$(_ON)) @$(call add,DEFAULT_SERVICES_DISABLE,$(_OFF)) -use/live/base: use/live use/syslinux/ui/menu +use/live/base: use/live use/net use/syslinux/ui/menu @$(call add,LIVE_LISTS,$(call tags,base && (live || network))) # rw slice, see http://www.altlinux.org/make-initrd-propagator and #28289 diff --git a/features.in/live/live/image-scripts.d/50-setup-network b/features.in/live/live/image-scripts.d/50-setup-network deleted file mode 100755 index e1bc6d17..00000000 --- a/features.in/live/live/image-scripts.d/50-setup-network +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# Setup network settings -# 1. Init /etc/hosts with "127.0.0.1 localhost" -# 2. Set hostname, domainname -# 3. Set defaults for NetworkManager or -# attempt to autoconfigure eth0 by etcnet. - -. shell-config - -verbose() -{ - if [ -n "$GLOBAL_VERBOSE" ]; then - echo "HOOK: 50-setup-network: $@" - fi -} - -verbose "has started" - -# At startup time hostname may be changed by live-hostname package. -HOSTNAME="localhost.localdomain" -DOMAINNAME="localdomain" - -verbose "Init /etc/hosts with 127.0.0.1 localhost" -echo "127.0.0.1 localhost localhost.localdomain" > /etc/hosts - -prefix="/etc/net/ifaces" - -# seems like aufs bug on O_TRUNC writes: -# aufs au_lkup_neg:267:kworker/0:2[998]: -# I/O Error, resolv.conf should be negative on b0. -# OTOH lo interface is now brought up in initrd -# so this shoudn't really matter -if [ -d "$prefix"/lo ]; then - echo 'nameserver 8.8.8.8' >> "$prefix"/lo/resolv.conf -fi -find /var -name resolv.conf -or -name nsswitch.conf -delete - -netcfg="/etc/sysconfig/network" - -verbose "Enable networking, set hostname to $HOSTNAME, domainname to $DOMAINNAME" -shell_config_set "$netcfg" NETWORKING yes -shell_config_set "$netcfg" HOSTNAME "$HOSTNAME" -shell_config_set "$netcfg" DOMAINNAME "$DOMAINNAME" - -# NB: see also #28484 and livecd-net-eth for runtime configuration -defcfg="$prefix/default/options-eth" -if [ -x /usr/sbin/NetworkManager -o -x /usr/sbin/connmand ] ; then - verbose "Setup defaults for NetworkManager/connman" - shell_config_set "$defcfg" NM_CONTROLLED yes - shell_config_set "$defcfg" DISABLED yes - shell_config_set "$defcfg" BOOTPROTO dhcp -else - # attempt to autoconfigure ethernet by etcnet - if [ -x /lib/udev/write_net_rules ] && - [ -x /sbin/dhcpcd -o -x /sbin/dhclient ]; then - verbose "configuring DHCP for eth0" - mkdir -p "$prefix"/eth0 && { - echo TYPE=eth - echo BOOTPROTO=dhcp - echo DHCP_TIMEOUT=3 - } > "$prefix"/eth0/options - else - verbose "NOT configuring eth0 for DHCP" - fi -fi - -verbose "finished" diff --git a/features.in/net/rootfs/image-scripts.d/50-net-resolv b/features.in/net/rootfs/image-scripts.d/50-net-resolv new file mode 100755 index 00000000..51aa57c1 --- /dev/null +++ b/features.in/net/rootfs/image-scripts.d/50-net-resolv @@ -0,0 +1,17 @@ +#!/bin/sh + +# offer some convenient servers for static configuration cases +if [ -d /etc/net/ifaces/lo ]; then + { + echo "# yandex" + echo "#nameserver 77.88.8.1" + echo "# google" + echo "#nameserver 8.8.8.8" + echo "# level3" + echo "#nameserver 4.2.2.3" + } >> /etc/net/ifaces/lo/resolv.conf +fi +find /var -name resolv.conf -or -name nsswitch.conf -delete + +# hasher might have carried host /etc/hosts over, need to overwrite +echo "127.0.0.1 localhost.localdomain localhost" > /etc/hosts