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}"
87 elif [ -z "${NETBOOT}" ] || [ -n "${DHCP}" ]
89 # default, dhcp assigned
92 # make sure that the preconfigured interface would not get reassigned by dhcp
93 # on startup by ifup script - otherwise our root fs might be disconnected!
97 # iterate the physical interfaces and add them to the interfaces list and also add when ethdevice= called on cmdline
98 if [ "${method}" != dhcp ] || ([ ! -x /root/usr/sbin/NetworkManager ] && [ ! -x /root/usr/sbin/wicd ]) || [ ! -z "${ETHDEVICE}" ]
100 for interface in /sys/class/net/eth* /sys/class/net/ath* /sys/class/net/wlan* /sys/class/net/en*
102 [ -e ${interface} ] || continue
103 i="$(basename ${interface})"
105 cat >> "${IFFILE}" << EOF
107 iface ${i} inet ${method}
114 if [ ! -f "${DNSFILE}" ] || [ -z "$(cat ${DNSFILE})" ]
116 if [ -f /netboot.config ]
118 # create a resolv.conf if it is not present or empty
119 cp /netboot.config /root/var/log/netboot.config
121 rc_search=$(cat netboot.config | awk '/domain/ { print $3 }')
122 rc_server0="$(cat netboot.config | awk '/dns0/ { print $5 }')"
124 cat > $DNSFILE << EOF
127 nameserver ${rc_server0}
130 rc_server1=$(cat netboot.config | awk '/dns0/ { print $8 }')
132 if [ "${rc_server1}" != "0.0.0.0" ]
134 echo "nameserver ${rc_server1}" >> $DNSFILE
137 cat $DNSFILE >> /root/var/log/netboot.config