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 DNSFILE="/root/etc/resolv.conf"
21 if [ "${STATICIP}" = "frommedia" ] && [ -e "${IFFILE}" ]
23 # will use existent /etc/network/interfaces
28 cat > "${IFFILE}" << EOF
30 iface lo inet loopback
37 if [ -z "${NETBOOT}" ] && [ -n "${STATICIP}" ] && [ "${STATICIP}" != "frommedia" ]
39 parsed=$(echo "${STATICIP}" | sed -e 's|,| |g')
41 for ifline in ${parsed}
43 ifname="$(echo ${ifline} | cut -f1 -d ':')"
44 ifaddress="$(echo ${ifline} | cut -f2 -d ':')"
45 ifnetmask="$(echo ${ifline} | cut -f3 -d ':')"
46 ifgateway="$(echo ${ifline} | cut -f4 -d ':')"
47 nameserver="$(echo ${ifline} | cut -f5 -d ':')"
49 cat >> "${IFFILE}" << EOF
50 allow-hotplug ${ifname}
51 iface ${ifname} inet static
56 if [ -n "${ifgateway}" ]
59 cat >> "${IFFILE}" << EOF
66 if [ -n "${nameserver}" ]
69 cat >> "${DNSFILE}" << EOF
70 nameserver ${nameserver}
76 if [ -z "${NETBOOT}" ] || [ -n "${DHCP}" ]
78 # default, dhcp assigned
81 # make sure that the preconfigured interface would not get reassigned by dhcp
82 # on startup by ifup script - otherwise our root fs might be disconnected!
86 # iterate the physical interfaces and add them to the interfaces list and also add when ethdevice= called on cmdline
87 if [ "${method}" != dhcp ] || ([ ! -x /root/usr/sbin/NetworkManager ] && [ ! -x /root/usr/sbin/wicd ]) || [ ! -z "${ETHDEVICE}" ]
89 for interface in /sys/class/net/eth* /sys/class/net/ath* /sys/class/net/wlan*
91 [ -e ${interface} ] || continue
92 i="$(basename ${interface})"
94 cat >> "${IFFILE}" << EOF
96 iface ${i} inet ${method}
103 if [ ! -f /root/etc/resolv.conf ] || [ -z "$(cat /root/etc/resolv.conf)" ]
105 if [ -f /netboot.config ]
107 # create a resolv.conf if it is not present or empty
108 cp /netboot.config /root/var/log/netboot.config
110 rc_search=$(cat netboot.config | awk '/domain/{print $3}')
111 rc_server0=$(cat netboot.config | awk '/dns0/{print $5}')
112 rc_server1=$(cat netboot.config | awk '/dns0/{print $8}')
113 rc_server0="nameserver ${rc_server0}"
115 if [ "${rc_server1}" = "0.0.0.0" ]
119 rc_server1="nameserver ${rc_server1}"
122 cat > /root/etc/resolv.conf << EOF
124 # Autogenerated by live-boot
131 cat /root/etc/resolv.conf >> /root/var/log/netboot.config
136 #if [ ! -x /root/usr/sbin/NetworkManager ]
138 # for i in eth0 eth1 eth2 ath0 wlan0
140 # grep -q "iface ${i}" ${IFFILE} && continue
142 #cat >> "${IFFILE}" << EOF
144 #iface ${i} inet dhcp