7 if [ -n "${NONETWORKING}" ]
12 # FIXME: stop hardcoding overloading of initramfs-tools functions
14 . /lib/live/boot/9990-initramfs-tools.sh
16 log_begin_msg "Preconfiguring networking"
18 IFFILE="/root/etc/network/interfaces"
19 if [ -L /root/etc/resolv.conf ] ; then
20 # assume we have resolvconf
21 DNSFILE="/root/etc/resolvconf/resolv.conf.d/base"
23 DNSFILE="/root/etc/resolv.conf"
26 if [ "${STATICIP}" = "frommedia" ] && [ -e "${IFFILE}" ]
28 # will use existent /etc/network/interfaces
33 cat > "${IFFILE}" << EOF
35 iface lo inet loopback
42 if [ -z "${NETBOOT}" ] && [ -n "${STATICIP}" ] && [ "${STATICIP}" != "frommedia" ]
44 parsed=$(echo "${STATICIP}" | sed -e 's|,| |g')
46 for ifline in ${parsed}
48 ifname="$(echo ${ifline} | cut -f1 -d ':')"
49 ifaddress="$(echo ${ifline} | cut -f2 -d ':')"
50 ifnetmask="$(echo ${ifline} | cut -f3 -d ':')"
51 ifgateway="$(echo ${ifline} | cut -f4 -d ':')"
52 nameserver="$(echo ${ifline} | cut -f5 -d ':')"
54 cat >> "${IFFILE}" << EOF
55 allow-hotplug ${ifname}
56 iface ${ifname} inet static
61 if [ -n "${ifgateway}" ]
64 cat >> "${IFFILE}" << EOF
71 if [ -n "${nameserver}" ]
73 if [ -e "${DNSFILE}" ]
75 grep -v ^nameserver "${DNSFILE}" > "${DNSFILE}.tmp"
76 mv "${DNSFILE}.tmp" "${DNSFILE}"
79 echo "nameserver ${nameserver}" >> "${DNSFILE}"
83 if [ -z "${NETBOOT}" ] || [ -n "${DHCP}" ]
85 # default, dhcp assigned
88 # make sure that the preconfigured interface would not get reassigned by dhcp
89 # on startup by ifup script - otherwise our root fs might be disconnected!
93 # iterate the physical interfaces and add them to the interfaces list and also add when ethdevice= called on cmdline
94 if [ "${method}" != dhcp ] || ([ ! -x /root/usr/sbin/NetworkManager ] && [ ! -x /root/usr/sbin/wicd ]) || [ ! -z "${ETHDEVICE}" ]
96 for interface in /sys/class/net/eth* /sys/class/net/ath* /sys/class/net/wlan*
98 [ -e ${interface} ] || continue
99 i="$(basename ${interface})"
101 cat >> "${IFFILE}" << EOF
103 iface ${i} inet ${method}
110 if [ ! -f "${DNSFILE}" ] || [ -z "$(cat ${DNSFILE})" ]
112 if [ -f /netboot.config ]
114 # create a resolv.conf if it is not present or empty
115 cp /netboot.config /root/var/log/netboot.config
117 rc_search=$(cat netboot.config | awk '/domain/ { print $3 }')
118 rc_server0="$(cat netboot.config | awk '/dns0/ { print $5 }')"
120 cat > $DNSFILE << EOF
123 nameserver ${rc_server0}
126 rc_server1=$(cat netboot.config | awk '/dns0/ { print $8 }')
128 if [ "${rc_server1}" != "0.0.0.0" ]
130 echo "nameserver ${rc_server1}" >> $DNSFILE
133 cat $DNSFILE >> /root/var/log/netboot.config